Sie sind auf Seite 1von 3

#include<iostream.h> #include<conio.

h> class student { public: int rno; char name[20]; void input() { cout<<"\n\nEnter the rno:\n"; cin>>rno; cout<<"\n\nEnter the name:\n"; cin>>name; } }; class test:public student { public: int m1,m2; void marks() { cout<<"\nEnter the marks of part1:\n"; cin>>m1;

cout<<"\nEnter the marks of part2:\n"; cin>>m2; } }; class sports { public: int s; void score() { cout<<"\nEnter the score obtained :\n"; cin>>s; } }; class result: public test,public sports { public: int total; void display() { total=m1+m2+s; cout<<"\nThe total score is:"<<total; } }; void main()

{ clrscr(); result r; r.input(); r.marks(); r.score(); r.display(); getch(); }

Das könnte Ihnen auch gefallen