#include<iostream.h>
#include<conio.h>
class parent
{
public:
virtual void show()=0; //IF THERE R 2 PURE VIRTUAL FUNCTIONS THEN THE CHILD CLASSES MUST HAVE BOTH THE VIRTUAL FUNCTIONS OVERRIDDED.
virtual void show1()=0;
};
class child1:public parent
{
public:
void show()
{
cout<<"child1 class: ";
}
void show1()
{
cout<<"child1: ";
}
};
class child2:public parent
{
public:
void show()
{
cout<<"child2 class: ";
}
void show1()
{
cout<<"child2: ";
}
};
void main()
{
parent * ptr[2];
ptr[0]=new child1;
ptr[1]=new child2;
ptr[0]->show();
ptr[0]->show1();
ptr[1]->show();
ptr[1]->show1();
getch();
}vi
#include<conio.h>
class parent
{
public:
virtual void show()=0; //IF THERE R 2 PURE VIRTUAL FUNCTIONS THEN THE CHILD CLASSES MUST HAVE BOTH THE VIRTUAL FUNCTIONS OVERRIDDED.
virtual void show1()=0;
};
class child1:public parent
{
public:
void show()
{
cout<<"child1 class: ";
}
void show1()
{
cout<<"child1: ";
}
};
class child2:public parent
{
public:
void show()
{
cout<<"child2 class: ";
}
void show1()
{
cout<<"child2: ";
}
};
void main()
{
parent * ptr[2];
ptr[0]=new child1;
ptr[1]=new child2;
ptr[0]->show();
ptr[0]->show1();
ptr[1]->show();
ptr[1]->show1();
getch();
}vi
0 comments:
Post a Comment