A
a
Hi,
I need clarification for virtual method and pure virtual method.
e.g
Class Base{
virtual void func(){
----
}
}
Class Child : public Base{
void func()
{
----
}
}
Child* child = new Child();
Base * base = child;
base->func(); //it will call the Child func, because func is declared as
virtual in Base class.
1> is it correct for the above? (The base->func() will call the Child func)
2> For the func of the Base class with virtual keyword, it still can have
the guts. Am I right?
3> If the func of the Base class is declared as virtual void func()=0, then
there is no gut for it. The gut is defined by the Child. Am I right?
I need clarification for virtual method and pure virtual method.
e.g
Class Base{
virtual void func(){
----
}
}
Class Child : public Base{
void func()
{
----
}
}
Child* child = new Child();
Base * base = child;
base->func(); //it will call the Child func, because func is declared as
virtual in Base class.
1> is it correct for the above? (The base->func() will call the Child func)
2> For the func of the Base class with virtual keyword, it still can have
the guts. Am I right?
3> If the func of the Base class is declared as virtual void func()=0, then
there is no gut for it. The gut is defined by the Child. Am I right?