qfedu-cpp-level/day2/homework/h6.cpp

22 lines
494 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 创建一个名为 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;
}