I'm trying to put a struct or a class into a vector... it seems to work alright but I would like to know how to use functions/variables from the class.
This attempt compiles but comes up with 6 digit numbers when I expect it to be 12. So how do you put a class into a vector and retrieve the information?Code:struct test { int aaa; }; int main() { vector<test> vec; test str; str.aaa=12; vec.push_back(str); cout<<vec[vec.size()].aaa; }
Thanks