How to make multiple instances of a class in C++ -
how create multiple class instances without individually typing in names?
int main(){ myclass myinstance_1; myclass myinstance_2; myclass myinstance_3; ... myclass myinstace_10; }
how create multiple class instances without individually typing in names?
the reply create array, not way tried it.
like this:
int main() { myclass myinstance[10]; for(int = 0; < 10; i++) { myinstance[i].myclassfunction(); } }
tip: don't utilize arrays, utilize std::vector
or std::array
.
(see reply @jarod42)
c++ class object
No comments:
Post a Comment