Hello friends,
I am first year Computer Science student. In our last lecture I learn about virtual function. I have written following program on virtual function, but problem is that it unable to call overridden virtual function. I don't know what is the mistake in my program. Please help me.
Code:
class SomeParamEg;
class IBases
{
public:
virtual void Func(SomeParams* params = NULL)
{
cout << "Bases funcs";
}
};
class DerivedsA : public IBases
{
public:
void Funcs()
{
cout << "DerivedsA funcs";
IBases::Funcs();
}
};
class DerivedsB : public IBases
{
public:
void Funcs()
{
cout << "DerivedsB funcs";
IBases::Funcs();
}
};
void FuncsCallers(IBases *instances1, IBases *instances2)
{
IBases *is1 = instances1;
IBasess *is2 = instances2;
i1->Funcs();
i2->Funcs();
}
DerivedsA *as = new DerivedsA;
DerivedsB *bs = new DerivedsB;
FuncCallers(as,bs);
Bookmarks