1 Star 0 Fork 1

llongger/Code_C++

forked from GodOuO/Code_C++ 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
18.Student_class.cpp 685 Bytes
一键复制 编辑 原始数据 按行查看 历史
GodOuO 提交于 2023-03-15 04:06 . Train
#include<iostream>
#include<string>
using namespace std;
/* 设计学生类:姓名,学号
可以赋值姓名学号,可以展示姓名学号
*/
class Student{
public:
string s_Name;
int s_Id;
void showStudent(){
cout<<"sName:\t"<<s_Name<<endl<<"s_Id:\t"<<s_Id<<endl;
}
void setStudent(string name,int id){
s_Id = id;
s_Name = name;
}
};
int main(){
Student s1;
s1.s_Id = 181203616;
s1.s_Name = "GodOuO";
s1.showStudent();
Student s2;
string name;
int num;
cout<<"Input Name:"<<endl;
cin>>name;
cout<<"Input Id:"<<endl;
cin>>num;
s2.setStudent(name,num);
s2.showStudent();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/llongger/codeCpp.git
git@gitee.com:llongger/codeCpp.git
llongger
codeCpp
Code_C++
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385