22 lines
494 B
C++
22 lines
494 B
C++
// 创建一个名为 Student 的类,具有成员变量 name 和 grade,以及成员函数 void study(char *course) ,用于表示某班级的某学生正在学习某一门课程。
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
class Student
|
|
{
|
|
public:
|
|
char name[32]; // 学生姓名
|
|
char grade[32]; // 班级名
|
|
void study(char *course)
|
|
{
|
|
cout << this->grade << "班的" << this->name << "同学正在学习" << course << endl;
|
|
}
|
|
};
|
|
|
|
int main()
|
|
{
|
|
|
|
return 0;
|
|
}
|