C++编程题,求求大佬了

2025-04-12 12:03:55
推荐回答(1个)
回答1:

代码:

#include

using namespace std;

class Worker

{

public:

Worker(string id,string nm,string s,float g):id(id),name(nm),sex(s),gz(g)

{}

void show() const

{

cout<<"工号:"<

cout<<"姓名:"<

cout<<"性别:"<

cout<<"工资:"<

}

private:

string id,name,sex;

float gz;

};

int main()

{

Worker w("emp101","李世民","男",8888.88);

w.show();

return 0;

}

运行结果截图: