Preview:
#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;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter