What if I want a derived class to first execute the base class method and then its own method redefinition?
I tried the following but it didn't work
Code:
#include <iostream>
class Base_c
{
public:
void vMethod(){std:: cout << "base" << std::endl;}
};
class Derived_c : public Base_c
{
virtual void vMethod(){std::cout << "intermediate" << std::endl;}
};
class Derived_2_c : public Derived_c
{
virtual void vMethod(){std::cout << "derived" << std::endl;}
};
int main()
{
Base_c *b;
Derived_2_c d;
b = &d;
b->vMethod();
}
i would like it to produce the (double) output
base
derived
it would be useful to handle both the base fields and the derived fuelds as well