速求看一看,瞧一瞧。

设计一个雇员类,假设雇员每小时20元,该类能够计算雇员的每日薪水,且每日工作小时(hours)×每小时薪水,通过show函数输出,并设计主函数进行测试。

回答如下:没想到这么简单的类,我居然不会写,勉强凑合,请过目,有错误请通知我

#include <iostream>
using namespace std;

class Employee{
    int fee=20;
    public:
        int hours;
    int show(int n){
        return fee*n;
    }
};

int main()
{    
    Employee employee;
    cout<<"请输入工作时间:";
    int n=employee.hours;
    cin>>n;
    int price=employee.show(n);
    cout<<"报酬为:"<<price<<endl;
}