帮忙解决string问题
#include<iostream>#include<string>
using namespace std;
class Student
{
protected:
string name;
char matric_no[15];
int status;
public:
Student()
{
cout<<"Calling constructor from the"<<"base class"<<endl;
}
void SetData()
{
cout<<"Enter name:";
cin<<name;
cout<<"Enter matric number:";
cin<<matric_no;
}
virtual void DisplayFees(){};
};
class PartTimeStudent:public Student
{
public:
PartTimeStudent();
void DisplayFees();
};
PartTimeStudent::PartTimeStudent()
{
cout<<"Entering constructor for class"<<"Part Time Student."<<endl;
}
void PartTimeStudent::DisplayFees()
{
cout<<"Hi,"<<name<<"!";
cout<<"Your fees is RM300. Thank you."<<endl;
}
class FullTimeStudent:public Student
{
public:
FullTimeStudent();
void DisplayFees();
};
FullTimeStudent::FullTimeStudent()
{
cout<<"Entering constructor for class"<<"Full Time Student."<<endl;
}
void FullTimeStudent::DisplayFees()
{
cout<<"Hello,"<<name<<"!";
cout<<"Your fees is RM200. Thank you."<<endl;
}
void main()
{
FullTimeStudent full_timer;
full_timer.SetData();
full_timer.DisplayFees();
PartTimeStudent part_timer;
part_timer.SetData();
part_timer.DisplayFees();
}