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

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

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -

asp.net - call stack missing info on mono with apache and mod_mono -