解法 #include <iostream.h> #include <string.h> class Student { private: char sid[10]; char sname[20]; static int n; public: Student(); Student(char *id,char *name); Student(const Student &stu); void DispID(); void DispName(); static void DispCount(); }; Student::Student() { strcpy(sid,"999"); strcpy(sname,"无名"); n++; } Student::Student(char *id,char *name) { strcpy(sid,id); strcpy(sname,name); n++; } Student::Student(const Student &stu) { strcpy(sid,stu.sid); strcpy(sname,stu.sname); n++; } void Student::DispCount() { cout<<" 共 "<<n<<" 名学生"; } void Student::DispID() { cout<<"学号:"<<sid; } void Student::DispName() { cout<<" 姓名:"<<sname; } int Student::n=0; void main() { Student s1; s1.DispID();s1.DispName();Student::DispCount();cout<<endl; Student s2("1001","李大鹏"); s2.DispID();s2.DispName();Student::DispCount();cout<<endl; Student s3=s2; s3.DispID();s3.DispName();Student::DispCount();cout<<endl; }
![cpp](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
- 粉丝: 0
- 资源: 2
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)