Example:
#include<iostream.h>
#include<conio.h>
class student
{
int id;
char name[20];
public:
void get();
void put();
};
class marks
{
int english, french, maths, total;
public:
void getdata();
void putdata();
};
void student :: get()
{
cout<<”Enter
the Student Info = ”;
cin>>id>>name;
}
void student :: put()
{
cout<<”Student Info”;
cout<<id<<name;
}
void marks :: getdata()
{
cout<<”Enter
Marks = ”;
cin>>english>>french>>maths;
total
= english+french+maths;
}
void marks :: putdata()
{
cout<<”Total Marks = ”<<total;
}
class result : public
student, public marks
{
Public:
};
void main()
{
clrscr();
result
r;
r.get();
r.getdata();
r.put();
r.putdata();
getch();
}
No comments:
Post a Comment