Please explain the mechanics of how it works.
class Parent { protected: int parentInt; public: void printInt() {std::cout << parentInt;} }; class Child : public Parent { private: int childInt; public: void printInt() { Parent::printInt(); std::cout << parentInt; } }; Parent* = kids[10]; kids[0] = new Child; I created an array of pointers of the parent type, but when I create an object of a child class, can I still put it in an array of pointers to the parent type? How it works?
That is, when creating an object, I am allocated so much memory that all my variables and methods fit there. In the successor, I, it turns out, add some more variables, that is, the object itself takes up more memory, but I can still access the pointer to the parent type, which, it seems, is smaller. I hope, clearly stated the idea. I myself do not understand well. :)