Good day! I have the following question. There is a base class that has three heirs. In the fourth class, objects of derived classes are created and methods are executed for each of these objects. How can you implement the implementation of these methods simply in a loop, running through an array of pointers to these objects? Thanks in advance!
class Base{ public: int n; virtual void cleanarrays()=0; }; class A : public Base{ public: void cleanarrays(); ar1[n]; }; class B : public Base{ public: void cleanarrays(); ar2[n]; }; class C : public Base{ public: void cleanarrays(); ar3[n]; }; class MyClass{ public: A a; B b; C c; void cleanarrays(); }; void MyClass::cleanarrays(){ a.cleanarrays(); b.deletehists(); c.deletehists(); }