Write a C++ program to enter the record of a student and print on the display screen by using the multiple inheritance.
#include <iostream>
using namespace std;
class Marks {
int marks;
public:
void setMarks(int m) {
marks=m;
}
int getMarks(){
return marks;
}
};
class Details {
string name;
public:
void setName(string n) {
name=n;
}
string getName(){
return name;
}
};
class Student: public Marks, public Details{
public:
void display(){
cout<<"\nName: "<<getName()<<endl;
cout<<"\nMarks: "<<getMarks()<<endl;
}
};
int main() {
Student s1;
s1.setName("Juma");
s1.setMarks(79);
s1.display();
return 0;
}
Comments
Leave a comment