Professional Documents
Culture Documents
Take a class „first‟ in which there is a method in public section namely show(). This method
prints the message “I am show method of class first”.
Take another class „second‟ which publicly inherits class first. The class second also contains
a method namely show which prints the message “I am show method of class second”.
class first
{
public:
void show()
{
cout<<"I am show method of class first";
}
};
public:
void show()
{
cout<<"\nI am show method of class second";
}
};
void main()
{
clrscr();
second obj;
obj.first::show(); //show() of class first being called
obj.second::show(); //show() of class second being called
getch();