It is necessary to call the ob2 object method from the ex1 method of the ob1 object, using the link located in the ob1 object vector
class cl_1 { vector <cl_1 *> children; } class cl_2 : public cl_1 { void exe() { ///// } } class cl_3 : public cl_1 { void message() { std::cout <<"Massage"; } } int main() { cl_2 ob1; cl_3 ob2; ob1.children.push_back(&ob2); ob1.exe(); }
((cl_3 *)children[0])->message();- Do you make a program for a massage room? - Igormessagemethod virtual. - VTTstatic_cast<cl_3 *>(children[0])->message();. - HolyBlackCat