Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- class Xclass {
- public:
- Xclass() {}
- ~Xclass() {}
- string y;
- int x;
- };
- int main(int argc, char** argv) {
- vector<Xclass> vx;
- int a=1000;
- int ktr=0;
- while(a>0) { //create 1000 objects of class Xclass
- Xclass xc;
- vx.push_back(xc);
- cout<<a<<endl;
- --a;
- ktr++;
- }
- vx.at(2).x=999; //set value to 3rd object.
- cout<<"\nKTR: "<<ktr<<" Vector Size: "<<vx.size()<<" Vector[2].x val: "<<vx.at(2).x<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement