13_1.cpp
来自「C语言基本程序」· C++ 代码 · 共 41 行
CPP
41 行
# include <iostream.h>
# include <string.h>
class employee
{
private:
char name[20];
int id;
int salary;
char title;
public:
void display();
employee()
{
strcpy(name,"Lei");
id = 1;
salary = 5000;
title = 'S';
}
};
void employee::display()
{
cout << "姓名:"<<name<<endl;
cout << "编号:"<<id<<endl;
cout << "薪水:"<<salary<<endl;
cout << "职位:"<<title<<endl;
}
void main()
{
employee e1,e2;
cout << "第1个对象的信息:"<<endl;
e1.display();
cout <<endl;
cout <<"第2个对象的信息:"<<endl;
e2.display();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?