I thought Inheritance does not inherit Constructor!?

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
class Employee
{
protected:
	char EmployeeID[7] , Name[21] , EmployeeType , Department[7],TelephoneNumber[8];
	int	count ;
public :
	//Constructor & Destructor 
	Employee() ;
	Employee(char *EID = " ",char *Namep = " " ,char EType = '@',char *D = " ",char *TelNo = " ",int C = 0) ;
	//****************************
	//Assessor method
	friend ifstream& operator >>(ifstream& , Employee&) ;
	char *Get_EmployeeID(){return EmployeeID ; };
	char *Get_Name(){return Name ;} ;
	char *Get_Department(){return Department ;} ;
	char *Get_TelephoneNumber(){return TelephoneNumber ;} ;
	int Get_count(){return count ;} ;
} ;

class Fulltime : public Employee
{
protected :
	int Salary ;
public :
	Fulltime() ;
	Fulltime(char *EID ,char *Namep ,char EType ,char *D ,char *TelNo,int C ,int S=0) ;

} ;


1
2
3
4
5
6
7
8
9
Fulltime :: Fulltime(char *EID  ,char *Namep ,char EType ,char *D ,char *TelNo,int C ,int S)
{

}

Fulltime::Fulltime() 
{

}


error
1>c:\users\oh\desktop\school work\computing\sp2007cw\part b\part b qns 2\part b qns 2\fulltime.cpp(4): error C2668: 'Employee::Employee' : ambiguous call to overloaded function
1> c:\users\oh\desktop\school work\computing\sp2007cw\part b\part b qns 2\part b qns 2\header.h(35): could be 'Employee::Employee(char *,char *,char,char *,char *,int)'
1> c:\users\oh\desktop\school work\computing\sp2007cw\part b\part b qns 2\part b qns 2\header.h(34): or 'Employee::Employee(void)'
1> while trying to match the argument list '(void)'


I don't understand my mistakes ! Someone help me!
I spotted a few mistakes below:

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
47
48
49
class Employee
{
protected:
	char EmployeeID[7] , Name[21] , EmployeeType , Department[7],TelephoneNumber[8];
	int	count ;
public :

	//Employee() ; 
	// Other constructor has all default parameters making
	// it ambiguous with this one -Galik

	Employee(char *EID = " ",char *Namep = " " ,char EType = '@',char *D = " ",char *TelNo = " ",int C = 0) ;
	//****************************
	//Assessor method

	// need to qualify the names of fstream with std:: -Galik
	friend std::ifstream& operator >>(std::ifstream& , Employee&);
	char *Get_EmployeeID(){return EmployeeID ; };
	char *Get_Name(){return Name ;} ;
	char *Get_Department(){return Department ;} ;
	char *Get_TelephoneNumber(){return TelephoneNumber ;} ;
	int Get_count(){return count ;} ;
} ;

class Fulltime : public Employee
{
protected :
	int Salary ;
public :
	Fulltime() ;
	Fulltime(char *EID ,char *Namep ,char EType ,char *D ,char *TelNo,int C ,int S=0) ;

};

Fulltime::Fulltime(char *EID  ,char *Namep ,char EType ,char *D ,char *TelNo,int C ,int S)
{

}

Fulltime::Fulltime()
{

}

// This function was not defined!!! -Galik
Employee::Employee(char *EID,char *Namep,char EType,char *D,char *TelNo,int C)
{

}
Employee(char *EID, char *Namep = " " ,char EType = '@',char *D = " ",char *TelNo = " ",int C = 0)

[edit]
Aww, too slow
Last edited on

With regards to this part...
Employee() ;
Other constructor has all default parameters making
it ambiguous with this one -Galik

can you explain to me ? thanks in advance

[edit] LOL blackcoder... Can you explain to me?
Last edited on
Employee(char *EID = " ",char *Namep = " " ,char EType = '@',char *D = " ",char *TelNo = " ",int C = 0);

All parameters of that constructor have default value so you can also call it like Employee();. How will it decide on what constructor to call?
O okay ty
Topic archived. No new replies allowed.