class Student //定义学生类Student
{
public:
void study();
void exam();
private:
string _name;
int _age;
};
上面的代码在类中声明了两个成员函数,现在需要在类外实现
void Student::study() //类外实现study()成员函数
{
cout << "学习C++" << endl;
}
void Student::exam() //类外实现exam()成员函数
{
cout << "C++考试成绩100分" << endl;
}