This Pointer
The keyword this represents a pointer to the object whose member function is being executed. It is a pointer to the object itself.
One of its uses can be to check if a parameter passed to a member function is the object itself. For example,
One of its uses can be to check if a parameter passed to a member function is the object itself. For example,
// this#include <iostream>using namespace std;class CDummy {public:int isitme (CDummy& param);};int CDummy::isitme (CDummy& param){if (¶m == this) return true;else return false;}int main () {CDummy a;CDummy* b = &a;if ( b->isitme(a) )cout << "yes, &a is b";return 0;}
تعليقات: 0
إرسال تعليق