Google News
logo
CPP - Interview Questions
What is this pointer?
The ‘this’ pointer is passed as a hidden argument to all nonstatic member function calls and is available as a local variable within the body of all nonstatic functions. ‘this’ pointer is a constant pointer that holds the memory address of the current object. ‘this’ pointer is not available in static member functions as static member functions can be called without any object (with class name).

#include <iostream>
#include <string>
using namespace std;

int main() {
  string education = "Free Time Learning";

  cout << education << "\n";
  cout << &education << "\n";
  return 0;
}​
Output : 

Free Time Learning
0x7ffecd166cb0
Advertisement