Thread: C++ Help
View Single Post
Old 03-19-07, 03:42 PM   #6
Subtestube's Avatar
Join Date: Aug 2004
Location: Wellington, New Zealand
Posts: 1,365
Default Re: C++ Help

You need to iterate _through_ the members of the deque.

Deques are nice general STL containers so you can do this in two ways. In the first, you can treat the deque like an array, and just make a for loop to go through it, using req[i].size() as your loop end condition - i.e., access each student _in_ each deque using req[i][j] as a way to reference each thing.

Alternatively, and in _much better_ STL style, you could use an iterator - make an iterator using deque<Student>::iterator iter = req[i].begin(), and iterate through the members from there. I'd give you code for that, but that's really doing all the work for you

EDIT: Sorry, had .front(), where I should've had .begin(). More the fool me!
Dr Possible: Core 2 Duo E6400 on Gigabyte GA-965P-DS4. Galaxy GeForce 7600GT. 2GB Corsair XMS 2 DDR2-6400 RAM (CL5). ATi Theatre 550 Pro. Windows XP MCE. All stored in Piano black Antec Sonata II, with a broken door.

Mobile: ASUS M2400N, Pentium M 1.5 GHz. 512 MB DDR RAM. Intel EXTREME graphics. Windows XP SP 2 / Ubuntu 5.10.

Ridiculous DOES not have an 'e' in it. It comes from "ridicule" and has less than nothing to do with the colour red.
Subtestube is offline   Reply With Quote