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
Post a Comment