Hey everyone, I need help on how to use the "this" pointer. And how can it be used in file handling stuff. . (like that seekg and seekp )pls can someone help me with an example! .?
A less crucial use is to write explicitly clear code:
1 2 3 4 5
T Foo::bar( const Foo & other ) {
this->gaz = other.gaz;
// the this is optional. One could have
gaz = other.gaz;
// instead, but more explicit code is, well, explicit
If you for some reason use ambiguously same name for member and argument, then the this is necessary:
1 2 3 4
T Foo::bar( const Bar & gaz ) {
this->gaz = gaz;
// the left side is member gaz
// the right side is function argument
There are times, when you do need to refer to the object: