#include<iostream>
#include<conio.h>
#include<stdio.h>
class student
{
int roll;
char name[20];
public:
void getDetails()
{
cout<<"Enter The Roll And Name Of Student:";
cin>>roll>>name;
//gets(name);
}
void putDetails()
{
cout<<"Roll is: "<<roll;
cout<<"Name is: "<<name;
}
};
class marks:public student
{
float m1,m2,m3;
public:
void getMarks()
{
cout<<"Enter the marks of two subject: ";
cin>>m1>>m2;
}
void putMarks()
{
cout<<"Marks Are: "<<m1<<" "<<m2;
}
protected:
int sum()
{
m3=m1+m2;
cout<<"sum of marks is: "<<m3;
return(m3);
}
};
class result:public marks
{
public:
void getData()
{
getDetails();
getMarks();
}
void putData()
{
putDetails();
PutMarks();
sum();
}
};
void main()
{
clrscr();
result obj;
obj.getData();
obj.putData();
getch();
}
No comments:
Post a Comment