There is a class:
class A { private: struct B { std::string W; }; BD[100]; public: A(){}; }; I need an array of instances of class A. Tell me how to do this?
There is a class:
class A { private: struct B { std::string W; }; BD[100]; public: A(){}; }; I need an array of instances of class A. Tell me how to do this?
For example,
A a[20]; Or is it not what you want?
If they need to be created at runtime, for example
A* a = new A[20]; The same array of 20 class elements. do not forget to delete them using delete[]a .
If only one -
A* a = new A; It is necessary to delete same delete , but already without parentheses: delete a; .
And - think about applying the vector vector<A> , which will do all the necessary manipulations for you.
new A[N] . This is written in any language textbook. - αλεχολυτSource: https://ru.stackoverflow.com/questions/509402/
All Articles
A a[N];- an array ofNelements of typeA- αλεχολυτ