Jun 6, 2006 #1 Lorey Programmer Joined Feb 16, 2003 Messages 88 Location 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}
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}
Jun 6, 2006 #2 cpjust Programmer Joined Sep 23, 2003 Messages 2,132 Location US What do you want to initialize it to? If you want to populate the vector when it's defined -- you can't do that. Upvote 0 Downvote
What do you want to initialize it to? If you want to populate the vector when it's defined -- you can't do that.
Jun 6, 2006 #3 NullTerminator Programmer Joined Oct 13, 1998 Messages 293 Location US 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); Upvote 0 Downvote
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);