Monday, April 5, 2021

hybrid inheritance (OOP) (24)

 #include<iostream>

using namespace std;

class student 

{

private:

int roll;

public:

void get_ro()

{

cout<<"get roll";

cin>>roll;

}

void put_data()

{

cout<<"the roll number is:"<<roll<<endl;

}

};

class test:public student

{

protected:

int t1,t2;

public:

void get_marks()

{

student::get_ro();

cout<<"enter:";

cin>>t1;

cin>>t2;

}

void put_marks()

{

student::put_data();

cout<<"your marks in english:"<<t1<<endl;

cout<<"your marks in programming:"<<t2<<endl;

}

};

class sport: public student

{

protected:

float sp;

public:

void get_marks()

{

student::get_ro();

cin>>sp;

}

void put_mark()

{

student::put_data();

cout<<"your marks in sport is:"<<sp<<endl;

}

};

class result:public test, public sport

{

private:

int total;

public:

void put()

{

test::get_marks();

}

void display()

{

test::put_marks();

total=t1+t2;

cout<<"the total number are:"<<total<<endl;

}

};

int main()

{



result x;

x.put();

x.display();

}

No comments:

Post a Comment