Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
1
Indexable
Never
#include <iostream>
#include <string>
using namespace std;

class Student {
protected:
    string name;
    int id;
public:
    Student(string n, int i) {
        name = n;
        id = i;
    }
};

class Sports : public Student {
protected:
    int sp_grade;
public:
    Sports(string n, int i, int g) : Student(n, i) {
        sp_grade = g;
    }
};

class Exam : public Student {
protected:
    int ex_grade;
public:
    Exam(string n, int i, int g) : Student(n, i) {
        ex_grade = g;
    }
};

class Result : public Sports, public Exam {
private:
    string result;
public:
    Result(string n, int i, int sp_g, int ex_g, string r) :
        Sports(n, i, sp_g), Exam(n, i, ex_g) {
        result = r;
    }

    void display() {
        cout << "Name: " << name << endl;
        cout << "ID: " << id << endl;
        cout << "Sports Grade: " << sp_grade << endl;
        cout << "Exam Grade: " << ex_grade << endl;
        cout << "Result: " << result << endl;
    }
};

int main() {
    Result r("John", 1234, 85, 90, "Pass");
    r.display();
    return 0;
}