Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a list of structs

Status
Not open for further replies.

Pyramus

Programmer
Dec 19, 2001
237
GB
It is possible to have a list of structs isn't it?

#include <list>

list <MY STRUCT> mylistofstructs;

That should work?
 
Of course it should, but only if the compiler knows in what namespace to find the identifier &quot;list&quot;. Put in the line

using namespace std;

right after the line

#include <list>

or, change

list<MYSTRUCT>

to

std::list<MYSTRUCT>
 
No sorry, that wouldn't work. I found out that the STL list can't take a structure as a data type, but it can take a class. Basically, structures are a waste of time, just use classes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top