Please help me to correct the errors in this code and run it on the program. Please if you are able to do it just becaus

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Please help me to correct the errors in this code and run it on the program. Please if you are able to do it just becaus

Post by answerhappygod »

Please help me to correct the errors in this code and run it on
the program. Please if you are able to do it just because I need it
to work fully
Write C++ program to declare student status, the program should
have class 1 insert student name and age call by reference, class 2
should insert student status (success, fail) using static member
function and inherit class 1, class 3 should insert subject name
inherit class 1, and class 4 inherit class 2&3 and test if
student success of not and display all information (student name,
age, success or not, subject name).
Where:
If success=1 and fail=0 display success
If success=0 and fail=1 display fail
-------------------------------------------------------------------------------------------------------
#include <iostream>
using namespace std;
class Student {
public:
string name;
int age;
Student(string name, int age)
{
this->name = name;
this->age = age;
}
};
class Result : public Student {
public:
static int success;
static int fail;
Result(string name, int age) : Student(name, age)
{
}
};
int Result::success = 0;
int Result::fail = 0;
class Subject : public Student {
public:
string name;
Subject(string name, int age, string sub) : Student(name,
age)
{
this->name = sub;
}
};
class Display : public Result, public Subject {
public:
Display(string name, int age, string sub) : Student(name, age),
Result(name, age), Subject(name, age, sub)
{
}
void show()
{
cout << Name: << name << endl;
cout << Age: << age << endl;
if (success == 1 && fail == 0) {
cout << Result: Success << endl;
}
else if (success == 0 && fail == 1) {
cout << Result: Fail << endl;
}
cout << Subject: << name << endl;
}
};
int main()
{
Display d("James", 20, "History");
d.success = 1;
d.fail = 0;
d.show();
return 0;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply