JBTALKS.CC

标题: C++ 的问题 [打印本页]

作者: 狂天使    时间: 2010-1-16 07:56 PM
标题: C++ 的问题
各位高手以下是我的题目

The Johnson C &E Construction Company is managing a large construction project that will require the use of three types of construction  workers: millwrights, ironworkers, and operating engineers. Johnson C &E has hired you to write a C++ program that will allow the company to maintain the following information about each construction worker hired for the job: name, address, telephone number, union affiliation, pay rate, hours worked, and job description.
Information regarding the three types of information for the construction worker types appears in the table below
Millwrights
Union: United Brotherhood of Carpenters

Job Description                                                PayRate

Superintendent                                                RM 29.95
General Foreman                                        RM 28.95
Foreman                                                        RM 27.95
Journeyman                                                        RM 26.95
Apprentice                                                        RM 21.56

Iron Workers
Union: International Association of Bridge,Structural, and Ornamental Iron Workers

Job Description                                                PayRate

Superintendent                                                RM 29.68
General Foreman                                        RM 28.68
Foreman                                                        RM 27.68
Journeyman                                                        RM 26.33





Operating Engineers
Union: International Union Operating Engineers

Job Description                                                PayRate

Superintendent                                                RM 31.90
General Foreman                                        RM 30.90
Foreman                                                        RM 29.90
Journeyman                                                        RM 28.90
Apprentice                                                        RM 27.10



Operating Engineer personnel also have a Class Number associated with each of the above job description. These potential Class Numbers are 1,2,3,4: for example, and Operating Engineer Apprentice may have a Class Number 3 or an Operating Engineer Foreman may have a Class Number 1, Millwrights have a union local number that must be associated with each millwright. Ironworkers have the name of a business agent that must be associated with each ironworker.

Write a C++ program that
a.        Create classes for each type of construction work, use inheritance, constructors, virtual function, exception handle , etc. in the solution to this question.
b.        Reads in the data from the file named construction.dat and then populate three arrays with those data.
c.        The three arrays should store the information about millwrights, ironworkers, and operating engineers.
d.        Your program should then print the data, first listing ironworkers, then millwrights, and finally operating emgineers.
作者: 狂天使    时间: 2010-1-16 08:03 PM
当我 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;
        
}
作者: JulyAngel    时间: 2010-1-17 11:43 PM
millwrights(char* , char* , char* , char* ,int =0, double,char*);
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)
{}


我猜想是少了*  還是 多了*

default argument missing for parameter 6 of `millwrights::millwrights(char*, char*, char*, char*, int, double, char*)'

int =0
跟上面是同一行
這是問題的根源

char get_jobtitle();
char* millwrights::get_jobtitle()


多了*

你的錯誤應該不只是那麼一兩段....
至少我的編譯器 不接受的地方多的很 T_T

我很多地方都沒有熟練 也不敢亂亂教人...

[ 本帖最后由 JulyAngel 于 2010-1-18 12:00 AM 编辑 ]




欢迎光临 JBTALKS.CC (https://jbtalks.my/) Powered by Discuz! X2.5