C
cindypwl
This is what I have
class base{public:virtual ~base();};
class derived1 : public base {};
class derived2 : public base {};
class A
{
public:
A(base *b_):b(b_) {
}
A(const A&a)
{
//What to do here *************
}
private:
base *b;
};
I'm not sure how to write the copy constructor to make sure it makes
the right copy of b.
How would the copy constructor know which derived type to copy?
class base{public:virtual ~base();};
class derived1 : public base {};
class derived2 : public base {};
class A
{
public:
A(base *b_):b(b_) {
}
A(const A&a)
{
//What to do here *************
}
private:
base *b;
};
I'm not sure how to write the copy constructor to make sure it makes
the right copy of b.
How would the copy constructor know which derived type to copy?