Using *this in C++ class method to fully overwrite self instantiation -


is following code safe? (i know compiles properly.)

void tile::clear() {     *this = tile(); }  int main() {     tile mytile;      mytile.clear(); } 

it might work. depends on how tile& operator = (const tile&); implemented. however, there's nothing intrinsically erroneous assigning *this new value.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -