Inheritance

PHOTO EMBED

Sun Jun 26 2022 13:10:16 GMT+0000 (UTC)

Saved by @Ranjan_kumar #c++

#include <bits/stdc++.h>
using namespace std;

class base
{
   public:
   int x;
   void show()
   {
      cout<<x<<"\n";
   }
};

class derived:public base       //Inheritance
{
   public:
   int y;
   
   void display()
   {
      cout<<x<<" "<<y<<"\n";
   }
};
int main()
{
	base b;
	b.x=4;
	b.show();
	derived d;
	d.x=10;
	d.y=5;
	d.show();
	d.display();
	
	return 0;
}
content_copyCOPY