no known conversion from class ‘Date’ to class ‘Date&’

Hi everyone! I have problems with class composition. I have a Date class where I can store dates, e.g. 12/27/2009, that is mm/dd/yy.
Then I have a class Employee, where in its constructor I use the class Date to store the Employee's Birthday. Here the "important" parts of class Date:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef DATE_H
#define DATE_H

#include <iostream>

using namespace std;

class Date
{
    public:
       Date(int m = 1, int d = 1, int y= 2000);		   
       void setDate(int, int, int);				
       
    
    private:
       int month;
       int day;
       int year;
       
 };

#endif




Here I have the Employee class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//Employee.h

#ifndef EMPLOYEE_H
#define EMPLOYEE_H

#include <string>
#include "Date.h"

using namespace std;

class Employee
{
public:
   Employee(const string &, const string &, const string &, const Date &);
   virtual ~Employee();
   
 ...
     

private:
   string firstName;
   string lastName;
   string socialSecurityNumber;
   Date birthday;
};

#endif 

//Employee.cpp

#include <iostream>
#include "Employee.h"
#include "Date.h"

using namespace std;

Employee::Employee(const string &first, const string &last, const string & ssn, const Date& dateOfBirth )
:birthday(dateOfBirth)
{
  setFirstName(first);
  setLastName(last);
  setSocialSecurityNumber(ssn);
  
}

...


Then I have subclasses inheriting from the Employee class, describing Employees with different types of salary: SalariedEmploee, CommissionEmployee,...

For instance, the class CommissionEmployee has the constructor:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef COMMISSION_H
#define COMMISSION_H

#include "Employee.h"

class CommissionEmployee : public Employee
{
  public :
    CommissionEmployee(const string &, const string &, const string &, Date&, double = 0.0, double = 0.0);
    
    ... 
    
  private:
    double commissionRate;
    double grossSales;

};

#endif 


When in the main I try to declare an object of the class CommissionEmployee, I would write:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <iomanip>
#include<vector>

#include "Employee.h"
#include "SalariedEmployee.h"
#include "HourlyEmployee.h"
#include "CommissionEmployee.h"
#include "BasePlusCommissionEmployee.h"

using namespace std;

int main()
{
  ...

CommissionEmployee commissionEmployee("Sue", "Jones", "333-33-3333", Date(1,1,1984), 0.06, 10000); //line 33

...



I try to compile and here's what I get:

jacopo@jacopo-laptop:~/Documenti/C++ Prove$ g++ EmployeeProgram.cpp Date.cpp Employee.cpp HourlyEmployee.cpp SalariedEmployee.cpp CommissionEmployee.cpp BasePlusCommissionEmployee.cpp -o EmployeeProgram
EmployeeProgram.cpp: In function ‘int main()’:
EmployeeProgram.cpp:33:97: error: no matching function for call to ‘CommissionEmployee::CommissionEmployee(const char [4], const char [6], const char [12], Date, double, int)’
EmployeeProgram.cpp:33:97: note: candidates are:
CommissionEmployee.h:9:5: note: CommissionEmployee::CommissionEmployee(const string&, const string&, const string&, Date&, double, double)
CommissionEmployee.h:9:5: note: no known conversion for argument 4 from ‘Date’ to ‘Date&’
CommissionEmployee.h:6:7: note: CommissionEmployee::CommissionEmployee(const CommissionEmployee&)
CommissionEmployee.h:6:7: note: candidate expects 1 argument, 6 provided


Could you explain me what's wrong with that?

Thanks!!!!!

Jac

Topic archived. No new replies allowed.