#include <bits/stdc++.h> // 包含所有标准库的头文件

using namespace std; // 使用命名空间std

/* 类,面向对象 */ class student // 定义一个名为student的类 { private: // 私有成员变量 string name; // 学生姓名 int ID; // 学生ID编号 protected: // 保护成员变量 public: // 公有成员变量

student(); // 构造函数,用来初始化对象
~student(); // 析构函数,用来销毁对象

void setName(string newName); // 设置学生姓名的方法
void setID(int newID); // 设置学生ID编号的方法
string getName(); // 获取学生姓名的方法
int getID(); // 获取学生ID编号的方法

}; // 类定义结束

#include bitsstdc++husing namespace std;类面向对象 class studentprivate string name; int ID;protectedpublic student;构造函数 ~student;析构函数 void setNamestring newName; void setIDint newID; string getName; int

原文地址: https://www.cveoy.top/t/topic/drqL 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录