C
ccs
First, no compiling error for the following code...
class CStudent
{
int id;
public:
CStudent(int i) : id(i);
};
class CTeam
{
CStudent s;
public:
CTeam(int i) : s(i) {}
CTeam(const CStudent& c) : s(c.s);
};
Is the code above correct to use intializer list for copy constructor?
Is it correct to have different initializer lists for CTeam(int i) and
CTeam(const CStudent& c)?
For statement "CTeam(const CStudent& c) : s(c.s);", is the default copy
constructor of CStudent triggered?
Is it necessary to define a copy constructor for CStudent to replace its
default one?
Thanks in advance!
class CStudent
{
int id;
public:
CStudent(int i) : id(i);
};
class CTeam
{
CStudent s;
public:
CTeam(int i) : s(i) {}
CTeam(const CStudent& c) : s(c.s);
};
Is the code above correct to use intializer list for copy constructor?
Is it correct to have different initializer lists for CTeam(int i) and
CTeam(const CStudent& c)?
For statement "CTeam(const CStudent& c) : s(c.s);", is the default copy
constructor of CStudent triggered?
Is it necessary to define a copy constructor for CStudent to replace its
default one?
Thanks in advance!