If
you want to execute the member function of derived class then, you can
declare display( ) in the base class virtual which makes that function
existing in appearance only but, you can't call that function. In order
to make a function virtual, you have to add keyword virtual in front of a
function - See more at:
http://www.programiz.com/cpp-programming/virtual-functions#sthash.GW9aLwY9.dpuf
Virtual Functions
Virtual Functions
If you want to execute the member function of derived class then, you can declare callfunc() in the base class virtual which makes that function existing in appearance only but, you can't call that function. In order to make a function virtual, you have to add keyword virtual in front of a function.
If
you want to execute the member function of derived class then - See
more at:
http://www.programiz.com/cpp-programming/virtual-functions#sthash.GW9aLwY9.dpuf
If
you want to execute the member function of derived class then - See
more at:
http://www.programiz.com/cpp-programming/virtual-functions#sthash.GW9aLwY9.dpuf
If
you want to execute the member function of derived class then, you can
declare display( ) in the base class virtual which makes that function
existing in appearance only but, you can't call that function. In order
to make a function virtual, you have to add keyword virtual in front of a
function - See more at:
http://www.programiz.com/cpp-programming/virtual-functions#sthash.GW9aLwY9.dpuf
If
you want to execute the member function of derived class then, you can
declare display( ) in the base class virtual which makes that function
existing in appearance only but, you can't call that function. In order
to make a function virtual, you have to add keyword virtual in front of a
function - See more at:
http://www.programiz.com/cpp-programming/virtual-functions#sthash.GW9aLwY9.dpuf
If
you want to execute the member function of derived class then, you can
declare display( ) in the base class virtual which makes that function
existing in appearance only but, you can't call that function. In order
to make a function virtual, you have to add keyword virtual in front of a
function - See more at:
http://www.programiz.com/cpp-programming/virtual-functions#sthash.GW9aLwY9.dpuf
If
you want to execute the member function of derived class then, you can
declare display( ) in the base class virtual which makes that function
existing in appearance only but, you can't call that function. In order
to make a function virtual, you have to add keyword virtual in front of a
function - See more at:
http://www.programiz.com/cpp-programming/virtual-functions#sthash.GW9aLwY9.dpuf
If
you want to execute the member function of derived class then, you can
declare display( ) in the base class virtual which makes that function
existing in appearance only but, you can't call that function. In order
to make a function virtual, you have to add keyword virtual in front of a
function - See more at:
http://www.programiz.com/cpp-programming/virtual-functions#sthash.GW9aLwY9.dpuf
If
you want to execute the member function of derived class then, you can
declare display( ) in the base class virtual which makes that function
existing in appearance only but, you can't call that function. In order
to make a function virtual, you have to add keyword virtual in front of a
function - See more at:
http://www.programiz.com/cpp-programming/virtual-functions#sthash.GW9aLwY9.dpuf
If
you want to execute the member function of derived class then, you can
declare display( ) in the base class virtual which makes that function
existing in appearance only but, you can't call that function. In order
to make a function virtual, you have to add keyword virtual in front of a
function - See more at:
http://www.programiz.com/cpp-programming/virtual-functions#sthash.GW9aLwY9.dpuf
#include<iostream>
#include<conio.h>
using namespace std;
class base
{
public:
virtual void callfunc()
{
cout << "base class...................."<< endl;
}
};
class drived1:public base
{
public:
void callfunc()
{
cout << "call first drived class...................."<< endl;
}
};
class drived2:public base
{
public:
void callfunc()
{
cout << "call the second drived class .............."<< endl;
}
};
int main()
{
base *b;
drived1 d1;
drived2 d2;
//base *b=&d1;
b= &d1;
d1.callfunc();
b=&d2;
b->callfunc();
getch();
return 0;
}