Closed Wanderson4096 closed 4 years ago
virtual c_wnd* clone(){return new c_button();}
clone function will be used when you want clone a same UI, even it is rarely used.
You refer to this code: clone 8 mini UI
This clone function will not actually clone the object. You are creating a default object (using the default constructor) and not a copy. To actually build a copy of the object, you have to pass a pointer to this object (*this) as the constructor parameter, like this:
virtual c_wnd* clone(){return new c_button(*this);} // Makes a copy and returns a pointer to it.
Maybe the name "clone" is not accurate. We just want a new c_wnd object, but do not want it's the same as its father.
remove the function
There is several clone functions that actually does not clone the object. Like the one in button.h, it needs a *this parameter in the constructor.