我根据我的理解创建了这个类,但是它给出了很多错误,我想做的是创建一个员工类,并且基本上学会了如何用它创建和操作对象。任何帮助是极大的赞赏。:)
#include <iostream>
#include <string>
using namespace std;
class employeeClass
{
private:
int emplNumber;
string empName;
string stAddress;
string phoneNumber;
double hourlyWage;
double hoursWorked;
public:
employeeClass();//not parametized constructor
employeeClass(int, string, string, string, double, double);
~employeeClass();//destructor to release memory if object assigned dynamic memory
void setEmpnumber();
int getEmpnumber();
void setEmpname();
string getEmpname();
void setstAddress();
string getstAddress();
void setphoneNumber();
string getphoneNumber();
void setHourlywage();
double getHourlywage();
void sethoursWorked();
double gethoursWorked();
employeeClass::employeeClass()
{
int emplNumber;
string empName;
string stAddress;
string phoneNumber;
double hourlyWage = 0;
double hoursWorked = 0;
}
employeeClass::employeeClass(int a, string b, string c, string d, double e, double f)
{
emplNumber=a;
empName=b;
stAddress=c;
phoneNumber=d;
hourlyWage=e;
hoursWorked=f;
}
void employeeClass::setEmpnumber(int a)
{
emplNumber=a;
}
int employeeClass::getEmpnumber()
{
return emplNumber;
}
void employeeClass::setEmpname(string b)
{
empName=b;
}
string employeeClass::getEmpname()
{
return emplNumber;
}
void employeeClass::setstAddress(string c)
{
stAddress=c;
}
string employeeClass::getstAddress()
{
return stAddress;
}
void employeeClass::setphoneNumber(string d)
{
phoneNumber=d;
}
string employeeClass::getphoneNumber()
{
return phoneNumber;
}
void employeeClass::setHourlywage(double e)
{
hourlyWage=e;
}
double employeeClass::getHourlywage()
{
return hourlyWage;
}
void employeeClass::sethoursWorked(double f)
{
hoursWorked=f;
}
double employeeClass::gethoursWorked()
{
return hoursWorked;
}
};
int main ()
{
employeeClass gama, tito;
gama.setEmpname("Gamaliel tellez");
gama.setphoneNumber("8018839494");
gama.setEmpnumber('12');
gama.setHourlywage('345');
gama.sethoursWorked('23');
cout<<"Employee info: "<<endl;
cout<<"Name: "<<gama.getEmpname<<endl;
cout<<"Phone number: "<<gama.getphoneNumber<<endl;
cout<<"Emp number: "<<gama.getEmpnumber<<endl;
cout<<"Hourly wage: $"<<gama.getHourlywage<<endl;
cout<<"Hours worked: "<<gama.gethoursWorked<<endl;
system ("PAUSE");
return 0;
}