- 分享
- 0
- 人气
- 0
- 主题
- 23
- 帖子
- 124
- UID
- 186218
- 积分
- 122
- 阅读权限
- 13
- 注册时间
- 2008-12-16
- 最后登录
- 2012-3-17
- 在线时间
- 358 小时
|
当我 compile 的时候出现以下的问题,请问如何解决,谢谢
In constructor `millwrights::millwrights(char*, char*, char*, char*, int, double, char*)':
default argument missing for parameter 6 of `millwrights::millwrights(char*, char*, char*, char*, int, double, char*)'
这是我的code,给位高手请给些意见
main.cpp
#include "worker.cpp"
#include "millwrights.cpp"
#include "ironworker.cpp"
#include "engineer.cpp"
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin;
millwrights print[50];
fin.open("construction.dat");
if(!fin) {
cerr << "Error: file could not be opened" << endl;
exit(1);
}
}
//worker.h
class worker
{
public:
worker(char = "", char = "", char = "", char = "",int =0);
~worker();
void set_values(char = "", char = "", char = "", char = "",int =0);
void print();
char get_name();
char get_address();
char get_telephone();
char get_union();
int get_hoursWorked();
protected:
char name;
char address;
char telephone;
char UnionAffiliation;
int hoursWorked;
};
//worker.cpp
#include "worker.h"
#include <iostream>
using namespace std;
worker::worker(char nm, char add, char tel, char ua,int hw)
{
name = nm;
address = add;
telephone = tel;
UnionAffiliation=ua;
hoursWorked=hw;
}
void worker::set_values(char nm, char add, char tel, char ua,int hw)
{
name = nm;
address = add;
telephone = tel;
UnionAffiliation=ua;
hoursWorked=hw;
}
void worker::print()
{
cout << "Name: " << name << endl;
cout << "Address: " << address << endl;
cout << "Telephone: " << telephone << endl;
cout << "Union Affiliation: " << UnionAffiliation << endl;
cout << "Hours Worked: "<< hoursWorked << endl;
}
char worker::get_name()
{
return name;
}
char worker::get_address()
{
return address;
}
char worker::get_telephone()
{
return telephone;
}
char worker::get_union()
{
return UnionAffiliation;
}
int worker::get_hoursWorked()
{
return hoursWorked;
}
worker::~worker()
{
}
//millwrights.h
class millwrights:public worker
{
public:
millwrights(char* , char* , char* , char* ,int =0, double,char*);
double get_pay();
double pay_rate();
char get_jobtitle();
void print();
private:
double payRate;
char jobtitle;
};
//millwrights.cpp
#include "millwrights.h"
#include <iostream>
using namespace std;
millwrights::millwrights(char nm, char add, char tel, char ua,int hw, double pay, char* job):
worker(nm, add, tel, ua,hw), payRate(pay), jobtitle(job)
{}
double millwrights::get_pay()
{
return payRate;
}
char* millwrights::get_jobtitle()
{
return jobtitle;
}
void millwrights::print()
{
worker::print();
cout << "Job's description: " << jobtitle << endl;
cout << "Pay Rate: " << payRate << endl << endl;
} |
|