Monday, 26 April 2021

Function overriding in C++

 #include<iostream.h>

#include<conio.h>

class A

{

public:

void show()

{

cout<<"Show-A"<<endl;

}

void display()

{

cout<<"Display"<<endl;

}

};

class B : public A

{

public:

void show()

{

cout<<"Show-B"<<endl;

}

};

int main()

{

clrscr();

B b;

b.show();

A a;

a.show();


b.display();

getch();

return 0;

}

No comments:

Post a Comment