Mar 17, 2012 at 11:44pm UTC
class employee1
{
employee1(
string _id="0",
string _name="0",
string _date="0",
string _phone="0",
string _email="0",
bool _sent=0,
string _notes="0"
):id(_id),name(_name),date(_date),phone(_phone),email(_email),sent(_sent),
notes(_notes){}
employee1(const employee1& copy)
{
name=date=phone=email=notes="0";
sent=0;
*this=copy;
}
};
class employee2:public employee1
{
employee2(employee1& copy=employee1(),
string _responsedate="0",string _application="0",string _resume="0",bool _callback=0,string _notes=0)
:responsedate(_responsedate),application(_application),resume(_resume),
callback(_callback)
{
(employee1&)*this=copy;
addnotes(_notes);
}
employee2(const employee2& copy)
{
responsedate=
application=
resume="0";
callback=0;
*this=copy;
}
}
void main()
{
employee1 e1; //ok
employee2 e2; //run time null pointer error
Mar 18, 2012 at 1:10am UTC
I have overloaded that operator in code as well I refuse to belive I need to pass all the members of the base class explicitly in the ctor
Last edited on Mar 18, 2012 at 1:11am UTC
Mar 18, 2012 at 1:27am UTC
If you define your copy constructor to call itself...what do you think will happen if it keeps calling itself?
Mar 18, 2012 at 2:02am UTC
i tried defining the member expmicitly within the copy ctor still null pointer
Mar 18, 2012 at 4:04am UTC
this doest solve the problem of not not being able to decalre a default employee2 e2; null pointer error
Mar 18, 2012 at 4:25am UTC
¿Could you please provide a minimal example that reproduces your issue?