I am writing a simple piece of code.
class A
{
public:
virtual func ()
{ // allocate memory
}
};
class B : public A
{
public:
func ()
{ // some piece of code
// but call base class same function Ist
}
}
main()
{
A *ptr = new B;
ptr->func () //here I want to call base class function first
//and then derived class function
// How to implement ??
}
-
How to call base class function first and then call same function from derived class ??.
I dont want to call each function explicetly, I will just call derived class function and the base class function should be automatically called. -
I dont want any constructor to call these functions.
-
Is there any way to implement this or this is all rubbish.
Call the method
funcof the parent class (you need to do this explicitly) in the implementation ofB: