1 Star 0 Fork 1

刘宝明/QT学习

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.cpp 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
刘宝明 提交于 2024-08-18 17:23 . 20240818修改
#include <iostream>
#include <windows.h> //解决cout中文输出乱码第一步
using namespace std;
class Student{
private:
string s_name;
string s_number;
int s_age;
public:
Student(){
s_name="小云";
s_number="008";
s_age=22;
}
Student(string name){
s_name=name;
s_number="008";
s_age=22;
}
Student(string name,string number){
s_name=name;
s_number=number;
s_age=22;
}
Student(string name,string number,int age){
s_name=name;
s_number=number;
s_age=age;
}
void show();
};
void Student::show(){
cout<<"The message is:"<<s_name<<"学号:"<<s_number<<"年龄:"<<s_age<<endl;
}
int main()
{
cout << "Hello World!" << endl;
SetConsoleOutputCP(CP_UTF8);//解决cout中文输出乱码第二步
cout<<endl;
cout<<"student1:"<<endl;
Student stu1;
stu1.show();
cout<<endl;
cout<<"student2:"<<endl;
Student stu2("小强");
stu2.show();
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liu-baoming123/qt-learning.git
git@gitee.com:liu-baoming123/qt-learning.git
liu-baoming123
qt-learning
QT学习
master

搜索帮助