C++ Inheritance, calling a derived function from the base class -


How do I call a derivative function from a base class? I mean, able to change a function from a base-derived class.

East. {public: void f1 (); Zero f2 (); }; Zero A :: F1 () {it-> F2 (); } / * Here a :: F2 () definition, etc. * / class B: public one {public: zero f2 (); }; / * Here B: F2 () Definition, etc. * / Zero Lala (int s) {a * o; // I want to be square 'A' in this specific example switch (squares) {case 0: // type b o = new b (); break; Case 1: // Type Si = New C (); // You know, ... break; } O-> F1 (); // I want it to make F1 call F1 on the derived class) Maybe I'm taking a wrong view, any comments about the different designs will be appreciated.

Declare f2 () virtual in the base class.

  class one {public: zero F1 (); Virtual zeros f2 (); };  

Then whenever the class derives the class from f2 () from the most derived class, depending on the type of the object, depending on the type of object The call will be made, not the type of pointer.


Comments

Popular posts from this blog

php - multilevel menu with multilevel array -

c# - TypeConverter in propertygrid only converts from string, not to -

jQuery UI: Datepicker month format -