Answer to Question #205536 in C++ for Ahmed Ali

Question #205536

Write a C++ program to enter the record of a student and print on the display screen by using the multiple inheritance.


1
Expert's answer
2021-06-11T00:10:18-0400


#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog