Pages

Saturday, May 10, 2025

Multiple Inheritance in OOPs

#include <iostream>
using namespace std;
// multiple inheritance

class Teacher {
public:
    int salary;
    string subject;
};

class Student {
public:
    int rollno;
    float cgpa;

};

class TA : public Teacher, public Student {
public:
    string name;
};



int main() {
    TA ta1;
    ta1.name = "debadutta";
    ta1.subject = "c++";
    ta1.cgpa = 9.1;

    cout << ta1.name << endl;
    cout << ta1.subject << endl;
    cout << ta1.cgpa << endl;

    return 0;
}

OUTPUT:
debadutta c++ 9.1

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...