Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 1065|回复: 2
打印 上一主题 下一主题

C++ 的问题

[复制链接]

23

主题

0

好友

122

积分

高级会员

Rank: 3Rank: 3Rank: 3

跳转到指定楼层
1#
发表于 2010-1-16 07:56 PM |只看该作者 |倒序浏览
各位高手以下是我的题目

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.




收藏收藏0

23

主题

0

好友

122

积分

高级会员

Rank: 3Rank: 3Rank: 3

2#
发表于 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;
        
}


回复

使用道具 举报

0

主题

9

好友

69

积分

中级会员

Rank: 2Rank: 2

3#
发表于 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 |联系我们 |隐私政策 |Share

GMT+8, 2024-10-28 07:21 PM , Processed in 0.115022 second(s), 27 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部