Create a class 'Degree' having a method 'getDegree' that prints "I got a degree". It has two subclasses namely 'Undergraduate' and 'Postgraduate' each having a method with the same name that prints "I am an Undergraduate" and "I am a Postgraduate" respectively. Call the method by creating an object of each of the three classes.

Create a class 'Degree' having a method 'getDegree' that prints "I got a degree". It has two subclasses namely 'Undergraduate' and 'Postgraduate' each having a method with the same name that prints "I am an Undergraduate" and "I am a Postgraduate" respectively. Call the method by creating an object of each of the three classes.





#include <iostream>
using namespace std;

class degree{
public:
degree()
{
cout<<"I got a degree."<<endl;
}
};
class undergraduate:public degree{
public:
undergraduate()
{
cout<<"I am an Undergraduate"<<endl;
}
};
class postgraduate:public degree{
public:
postgraduate()
{
cout<<"I am a Postgraduate";
}
};
int main()
{
undergraduate u;
postgraduate p;

}


Create a class 'Degree' having a method 'getDegree' that prints "I got a degree". It has two subclasses namely 'Undergraduate' and 'Postgraduate' each having a method with the same name that prints "I am an Undergraduate" and "I am a Postgraduate" respectively. Call the method by creating an object of each of the three classes.