So you want to create X objects where X is a dynamic variable?
I think a std::vector should do what you want: (Not tested)Code:#include <vector> class SomeClass { public: SomeClass() {} SomeClass(const SomeClass& p_crCopy) {(*this) = p_crCopy;} ~SomeClass() {} private: // Member variables public: void DoYourThing(); { // Do something here } SomeClass& operator = (const SomeClass& p_crCopy) { // Copy any member variables here } }; int main() { std::vector<SomeClass> TheVector; unsigned int X = 20; // Create X SomeClass objects: TheVector.resize(X); // Access the 10th object: TheVector[10].DoYourThing(); }




Reply With Quote