Page 200 - DCAP404 _Object Oriented Programming
P. 200
Unit 9: Inheritance
{ cout << “Roll No.: “<< r_no<<“In”;} Notes
};
class test : virtual public student //Virtually
declared common
{ //base class 1
protected:
int para1;
int para2;
public:
void get_m (int x, int y)
{ part1= x; part2=y;}
void put.m (void)
{
cout <<“marks obtained: “<< “In”;
cout << “part1 = “ << part1 <<“In”;
cout << “part2 = “<< part2 << “In”;
}
};
class sports: public virtual student //virtually
declared common
{ //base class 2
protected:
int score;
public:
void get_s (int a) {
score = a;
}
void put_s (void)
{ cout << “sports wt.: “<<score<< “\n”;}
};
class result: public test, public sports //derived class
{
private : int total;
public:
void show (void);
};
void result : : show (void)
{ total = part1 + part2 + score;
LOVELY PROFESSIONAL UNIVERSITY 193