I believe your compiler is warning you because you are using heap-allocated (new'ed) data in your class and haven't defined operator= .
It could be that it isn't even heap-allocated memory, it could be a pointer to anything but your compiler probably doesn't realize this.
The compiler will create operator= for you but it will perform a shallow copy, not a deep copy.
In other words it will copy the pointer address of the data, it will not re-allocate space and copy the new'ed data.
An example:
#include <iostream>
class Test
{
public:
Test()
{
myData = new int;
printf("Created data: 0x%08X\n", myData);
}
~Test()
{
printf("Destroying data: 0x%08X\n", myData);
delete myData;
}
private:
int* myData;
};
int main(int argc, char* argv[])
{
Test test1;
Test test2;
test2 = test1;
Test test3(test1);
} This will produce output similar to:
Created data: 0x00333FC8
Created data: 0x00333148
Destroying data: 0x00333FC8
Destroying data: 0x00333FC8
Destroying data: 0x00333FC8 As you can see, this leaks memory (test2's data, 0x00333148), and triple-frees memory (0x00333FC8).