原文自http://see.xidian.edu.cn/cpp/biancheng/view/244.html
#include
#include
using namespace std;
//声明基类Student
class Student
{
public:
Student(int, string,float); //声明构造函数
void display( );//声明输出函数
protected: //受保护成员,派生类可以访问
int num;
string name;
float score;
};
//Student类成员函数的实现
Student::Student(int n, string nam,float s)//定义构造函数
{
num=n;
name=nam;
score=s;
}
void Student::display( )//定义输出函数
{
coutdisplay( );
pt=&grad1;
pt->display( );
return 0;
}
授权协议:创作共用 署名-非商业性使用 2.5 中国大陆
除注明外,本站文章均为原创;转载时请保留上述链接。