帮忙解决问题
#include<iostream>#include<string>
using namespace std;
class CollegeCourse
{
protected:
string department_name;
string course_id;
int credit_hour;
float tuition_fee;
void ShowProperties();
public:
CollegeCourse(){};
void SetProperties(string i_department_name,string i_course_id,
int i_credit_hour,float i_tuition_fee);
};
void CollegeCourse::SetProperties(string i_department_name,string i_course_id,
int i_credit_hour,float i_tuition_fee)
{
department_name=i_department_name;
course_id=i_course_id;
credit_hour=i_credit_hour;
tuition_fee=i_tuition_fee;
}
void CollegeCourse::ShowProperties()
{
cout<<"Department:"<<department_name<<endl;
cout<<"Course:"<<course_id<<endl;
cout<<"Credit Hour:"<<credit_hour<<endl;
cout<<"Tuition Fee:"<<tuition_fee<<endl;
}
class LabCourse:public CollegeCourse
{
private:
float lab_fee;
public:
LabCourse(){};
//overloading the function with the same name in the base class
void SetProperties(string i_department_name,string i_course_id,int i_credit_hour,
float i_tuition_fee,float i_lab_fee);
//overiding the protected access control
CollegeCourse::ShowProperties;
};
void LabCourse::SetProperties(string i_department_name,string i_course_id,int i_credit_hour,
float i_tuition_fee,float i_lab_fee)
{
//overriding a function with similar name but in the base class
CollegeCourse::SetProperties(i_department_name,i_course_id,i_credit_hour,
i_tuition_fee);
lab_fee=i_lab_fee;
}
void main()
{
CollegeCourse my_college;
my_college.SetProperties("JTMK","F3031",4,200);
LabCourse my_lab;
my_lab.SetProperties("JTMK","F3031",4,200,100);
my_lab.ShowProperties();
}