请高手帮我看一下这段C++程序的问题出在哪?
#include<iostream>usingnamespacestd;classWorkerPay{private:charlname[10];charfname[10...
#include <iostream>
using namespace std;
class WorkerPay
{
private:
char lname[10];
char fname[10];
float payrate;
char time[5];
int hour;
int min;
public:
WorkerPay ()
{ hour = min = payrate = 0; }
WorkerPay (int, int, float);
void setlname(char lastname[10]);
void setfname(char firstname[10]);
void settime();
void getlname();
void getfname();
int gettime();
};
void WorkerPay::setlname(char lastname[10])
{
strcpy(lname, lastname);
}
void WorkerPay::setfname(char firstname[10])
{
strcpy(fname, firstname);
}
void WorkerPay::getlname ()
{
cout << lname;
}
void WorkerPay::getfname ()
{
cout << fname;
}
int main ()
{
WorkerPay worker1;
char ln[10];
char fn[10];
cout << "Please input the worker’s last name, first name, pay rate, " << endl;
cout << "start time, and end time from Monday through Friday separated " << endl;
cout << "by space. (Enter -1 to end the input)" << endl;
cin >> ln >> fn;
worker1.setlname (ln);
worker1.setfname (fn);
cout << endl;
worker1.getlname ();
cout << " ";
worker1.getfname ();
return 0;
} 展开
using namespace std;
class WorkerPay
{
private:
char lname[10];
char fname[10];
float payrate;
char time[5];
int hour;
int min;
public:
WorkerPay ()
{ hour = min = payrate = 0; }
WorkerPay (int, int, float);
void setlname(char lastname[10]);
void setfname(char firstname[10]);
void settime();
void getlname();
void getfname();
int gettime();
};
void WorkerPay::setlname(char lastname[10])
{
strcpy(lname, lastname);
}
void WorkerPay::setfname(char firstname[10])
{
strcpy(fname, firstname);
}
void WorkerPay::getlname ()
{
cout << lname;
}
void WorkerPay::getfname ()
{
cout << fname;
}
int main ()
{
WorkerPay worker1;
char ln[10];
char fn[10];
cout << "Please input the worker’s last name, first name, pay rate, " << endl;
cout << "start time, and end time from Monday through Friday separated " << endl;
cout << "by space. (Enter -1 to end the input)" << endl;
cin >> ln >> fn;
worker1.setlname (ln);
worker1.setfname (fn);
cout << endl;
worker1.getlname ();
cout << " ";
worker1.getfname ();
return 0;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询