class Student //定义学生类Student
{
public:
void study();
void exam();
private:
string _name;
int _age;
};
The above code declares two member functions in the class, and now they need to be implemented outside the class
void Student::study() //类外实现study()成员函数
{
cout << "学习C++" << endl;
}
void Student::exam() //类外实现exam()成员函数
{
cout << "C++考试成绩100分" << endl;
}