Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Every object in C++ has access to its own address through a special pointer called this. It's an implicit parameter to all non-static member functions.
class Employee {
int id;
public:
void setId(int id) {
this->id = id; // Resolves naming conflict
}
Employee* getSelf() {
return this; // Returns current object address
}
};Distinguishes between member variables and local parameters with the same name.
Allows method chaining by returning *this from member functions.
static member functions do NOT have a this pointer because they are not associated with any specific object.