p9 简单的类.cpp
来自「谭浩强 《C++ 程序设计》第三版的部分课后练习题源码」· C++ 代码 · 共 34 行
CPP
34 行
#include<iostream>
using namespace std;
class student
{ private:
char name[10];
int number;
int score;
public:
void studata()
{ cout<<"please input the name: ";
cin>>name;
cout<<"please input the number: ";
cin>>number;
cout<<"please input the score: ";
cin>>score;
}
void disply()
{ cout<<"name: "<< name<<endl;
cout<<"number: "<< number<<endl;
cout<<"score: "<< score<<endl;
}
};
student stu1,stu2;
int main()
{ stu1.studata();
stu2.studata();
stu1.disply();
stu1.disply();
system("pause");
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?