我在为我的类创建对象时遇到问题,尝试使用已定义的数据成员创建类对象时遇到错误。
// class header for employee
#pragma once
#include <string>
#include <iostream>
class Employee
{
private:
std::string name;
int empnum;
std::string address;
std::string phone;
double hourwage;
double hoursworked;
public:
Employee(void);
Employee(int, std::string , std::string, std::string, double, double);
double gethourwage () const;
double gethoursworked () const;
double printcheck () const;
std::string getphone() const;
std::string getname() const;
std::string getaddress() const;
};
// end of header
// employee class.cpp
#include "Employee.h"
#include <string>
#include <iostream>
Employee::Employee(void)
{
int empnum = 0;
double hourwage = 0.0;
double hoursworked = 0.0;
}
Employee::Employee(int num, std::string nme, std::string addres, std::string phon, double hourpay, double hrswrked)
{
num = empnum;
nme = name;
addres = address;
phon = phone;
hourpay = hourwage;
hrswrked = hoursworked;
}
double Employee::gethourwage() const
{
return hourwage;
}
double Employee::gethoursworked() const
{
return hoursworked;
}
double Employee::printcheck() const
{
double pay = 0.0;
double hrspay = hourwage;
double hrswork = hoursworked;
return hoursworked;
}
// end of employee.cpp
// main
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <string>
#include "Employee.h"
using namespace std;
int main( )
{
int num1 = 10210;
double hourwage = 20.2;
double hourworked = 32.3;
string steve;
Employee emp(num1, steve, 58s200w, 90210, hourwage, hourworked);
cout << "" << emp.getaddress();
system("PAUSE");
return 0;
} // end of main
“员工 emp(num1, steve, 58s200w, 90210, hourwage, hourwork);” 靠近底部的是我遇到问题的那条线。我不确定我输入的顺序是否错误,或者其他什么。
提前感谢您的帮助。