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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to initialize vector of structure?

Status
Not open for further replies.

Lorey

Programmer
Feb 16, 2003
88
SG
HI!

Anybody knows how to initialize a vector of structure?


Like std::vector<std::vector<structtype>>
where struct structtype {std::String s; unsigned long n}
 
What do you want to initialize it to?
If you want to populate the vector when it's defined -- you can't do that.
 
This looks like a two dimensional vector of structures

// make sure to put a space between the two > >'s
std::vector<std::vector<structtype> > vvs;
std::vector<structtype> vs

vs.push_back( structype("some string", 15) );
vvs.push_back(vs);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top