-
Hey, first thanks a lot for your help guys!
I figured out what was wrong
Code:
class derived : public base
{
public:
int i2;
derived(int a1, int a2) : base(a1), i2(a2) {}
derived(const derived &o) : base(o), i2(o.i2) {}
derived &operator =(const derived &o) {
base::operator=(o);
i2 = o.i2;
return *this;
}
};
Forgot to pass reference of derived to base class in constructor..
Didnt expect this will happen.. whys that?
-
Because it is more consistent to say that uninitialized sub-objects are initialized with the default constructor in all constructor initialization lists than making a special exception for the copy constructor.