Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

HEIRARCHIAL INHERITANCE in C++

#include<iostream.h>
#include<conio.h>
int tot;
class stu {
public:
int m1,m2,roll;
void get()  {
cout<<"enter rollno";
cin>>roll; }    };

class test:public stu    {
public:
void mark()    {
cout<<"enter the marks";
cin>>m1>>m2;    }};

class sport:public stu {
public:
int a;    char game[25];
void put(int t)    {
cout<<"enter game:";    cin>>game;
cout<<"enter score:";    cin>>a;
cout<<game;    
cout<<"the overall total is:" << t+a;            
}};

class result:public stu {
public:
int add()    { cout<<"rollno:"<<roll;
tot=m1+m2;
cout<<"the total marks" << tot;
return tot;        }};

void main()    {
clrscr();    
result r;    
sport r;
test n;    
r.get();    
n.mark(); 
r.add();    
s.put(tot); 
getch();}