Can we have a complete test case, please? Something like this:
Code:
#include <iostream>
class base
{
public:
int i1;
base(int a1) : i1(a1) {}
base(const base &o) : i1(o.i1) {}
base &operator =(const base &o) { i1 = o.i1; return *this; }
};
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;
}
};
int main()
{
derived d1(10, 15);
derived d2(20, 25);
d1 = d2;
std::cout << "d1: " << d1.i1 << ", " << d1.i2 << "\n";
}
This does exactly what is expected. How does your code differ?