How to create a dynamic array of class in C++ -


i know how create class array dynamically, tried doing

class a{ public: int a; int b; }  main(){ *temp; temp[somevalue] = new (temp) } 

but issue dont want limit array somevalue want extend it, thought of using std::vector , std::list stuck in implementation

simple example of std::vector:

class myclass { public:     int a;     int b;      myclass(int a, int b) : a(a), b(b) { } };  std::vector<myclass> temp; temp.push_back(myclass(1, 2)); temp.push_back(myclass(3, 4)); // temp vector contains 2 items 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -