#include<iostream.h>
#include<conio.h>
class parent
{
public:
virtual void show()=0;
};
class child1:public parent
{
public:
void show()
{
cout<<"child1 class: ";
}
};
class child2:public parent
{
public:
void show()
{
cout<<"child2 class: ";
}
};
void main()
{
parent * ptr[2];
ptr[0]=new child1;
ptr[1]=new child2;
ptr[0]->show();
ptr[1]->show();
getch();
}
#include<conio.h>
class parent
{
public:
virtual void show()=0;
};
class child1:public parent
{
public:
void show()
{
cout<<"child1 class: ";
}
};
class child2:public parent
{
public:
void show()
{
cout<<"child2 class: ";
}
};
void main()
{
parent * ptr[2];
ptr[0]=new child1;
ptr[1]=new child2;
ptr[0]->show();
ptr[1]->show();
getch();
}
0 comments:
Post a Comment