Is there a good and bad about this design?
I'd like to look deeper into a good design of a class, mainly that would assumably be instantiated multiple times and used on the heap where bitmaps and other data would be included for objects that might be a couple hundred or many hundreds of bytes at a time, or mb's.
What happens when this class is instantiated with these examples:Code:class SomeObject { public: SomeObject() { a = 0; b = 0; x = 0; y = 0; }; void SomeObject(int it) { InitObject(it); }; ~SomeObject() { a = 0; delete b; delete x; delete[] y; }; void InitObject(int it) { a = it; b = new int(it); x = new SomeThing(it); y = 0; ChangeTheItems(it); }; void ChangeTheItems(int it) { if(y != NULL) delete[] y; y = new SomeItem[it]; }; SomeItem* UseItems(void) { return y; }; //other functions here... private: int a; int* b; SomeThing* x; SomeItem* y; }
Any offerings about this?Code:[scope] SomeObject one; SomeObject two(3); SomeObject* buckle = new SomeObject(2); SomeObject* shoes = new SomeObject[100]; // blah lbah delete buckle; delete[] shoes; [/scope]