Dev C++ Operator Not Defined
Almost all operators can be overloaded for user-defined types, with a few notable exceptions such as member access (. And.) as well as the conditional operator. The rich set of overloadable operators is central to making user-defined types in C seem like built-in types.
Hi, I am newbie in C++. In a C++ Program, i am getting error message as 'Double freeing of freed memory may be in class 'WSO'. copy constructor and operator= is not defined.' I haven't defined any copy-constructor and operator overloading in Class 'WSO' (since i haven't use any assignment or copying object sort of things). Private member function of Class CNN uses a object pointer of another class 'NSA'. I used copy-constructor for this calss 'NSA'.
So my question is what could be the possibility of double freeing the memory.
destructor of Class 'WSO' just deletes pointer member of class 'NSA'.
- 2 Contributors
- forum 3 Replies
- 1,042 Views
- 6 Hours Discussion Span
- commentLatest Postby dewyattLatest Post
dewyatt-2
Dev C Operator Not Defined In English
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.
Dev C++ Operator Not Defined Working
An example:
This will produce output similar to:
Dev C++ Operator Not Defined Download
As you can see, this leaks memory (test2's data, 0x00333148), and triple-frees memory (0x00333FC8).