There are supposed to be three class definitions:
-DerivedClass1 which inherits BaseClass
-DerivedClass2 which inherits BaseClass
And here is some sample code that utilizes these classes and calls some AddChild and RemoveChild methods I need to write.
//create the main object BaseClass* testParentClass = new DerivedClass1(3, 4); //create child objects BaseClass* testChildClass1 = new DerivedClass2("john", 1, 2); BaseClass* testChildClass2 = new DerivedClass2("mark", 7, 5); //add child objects testParentClass->AddChild(testChildClass1); testParentClass->AddChild(testChildClass2); testParentClass->RemoveChild(testChildClass1);
And though I understand everything else, I have no idea how to approach this part. At first I thought you'd just have an array of type BaseClass within the definition of BaseClass, but the way the example code add's children isn't as if it's an array at all. It references the added children by name. I can't think of any way this could work.
At no point is anything referenced with an index. Not during the add or a remove. So isn't this something different from an array or vector?