C++类的继承与派生,这个程序是如何运行的

2025-03-26 07:17:48
推荐回答(1个)
回答1:

#include 
#include 

using namespace std;
class Person
{
protected:
string mName;
public:
Person(string name);
virtual void PrintSelfInfo();
};
Person::Person(string name)
{
mName = name;
}
void Person::PrintSelfInfo()
{

}
class Student : public Person
{
public:
//专业
enum Major
{
M_MATH,
M_COMPUTER_NET,
M_COMPUTER_PROGRAM,
};
protected:
Major mMajor; //专业
public: