Re: [Dev-C++] Vector of objects problem
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <age...@co...> - 2004-08-12 20:27:33
|
Instead of declaring it vector<students> kids[10], you must do it like this: vector<students> kids(10). The brackets create ten empty vectors. The parenthesis are used to create a vector of so many elements. Also, instead of cout << kids[3].fname, you can use an iterator. -- ~~Scott Simontis~~ > Hi all, > > Thank you in advance for any help you can offer. > I want to create a vector of student objects and then access the members > of the objects. > I started with: > > vector<students> kids[10]; // to declare a vector of 10 student > objects named kids > then I wanted to: > cout << kids[3].fname << endl; // fname is a string member in my > student class. > > This won't compile. It gives me only an ' as the message for the error. > > What am I doing wrong? > > Best regards, > > Dane > > > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |