So I have this class that has three parent functions, or in other words, it is derived from three other classes.
I'm trying to make a copy constructor, and this is what I have:
// Copy constructor
extPersonType (extPersonType &obj) : addressType(obj), personType(obj), dataType(obj)
{
cout << "Copy constructor active." << endl;
phone = obj.phone;
ident = obj.ident;
}
and here are my copy constructors for the three other classes.
// copy constructor
addressType(extPersonType &obj)
{
street = obj.street;
city = obj.city;
state = obj.state;
zipcode = obj.zipcode;
}
// copy constructor
personType(extPersonType &obj)
{
firstname = obj.firstname;
lastname = obj.lastname;
}
// copy constructor
dataType(extPersonType &obj)
{
day = obj.day;
month = obj.month;
year = obj.year;
}
Keep in mind they each have their own header files and cpp files. Although in this case I used inline function definition.
And yet here is the error I am getting:
[traine@joker Assignment2]$ make
g++ ExtPerson.cpp -c
In file included from ExtPerson.h:5:0,
from ExtPerson.cpp:3:
Data.h:19:26: error: expected ‘)’ before ‘&’ token
dataType(extPersonType &obj)
^
In file included from ExtPerson.h:6:0,
from ExtPerson.cpp:3:
Person.h:18:28: error: expected ‘)’ before ‘&’ token
personType(extPersonType &obj)
^
In file included from ExtPerson.h:7:0,
from ExtPerson.cpp:3:
Address.h:20:29: error: expected ‘)’ before ‘&’ token
addressType(extPersonType &obj)
^
make: *** [ExtPerson.o] Error 1
Anyone know what I'm doing wrong? I'm just confused on how to make copy constructors in a derived class, and how to call the other copy constructors in the other classes. Any help would be appreciated, thanks.