• Tutorials
  • Courses
  • Tracks

C++ | this pointer | Question 4

Last Updated :
Discuss
Comments
Predict the output of following C++ program CPP
#include<iostream>
using namespace std;

class Test
{
private:
  int x;
  int y;
public:
  Test(int x = 0, int y = 0) { this->x = x; this->y = y; }
  static void fun1() { cout << "Inside fun1()"; }
  static void fun2() { cout << "Inside fun2()"; this->fun1(); }
};

int main()
{
  Test obj;
  obj.fun2();
  return 0;
}
Inside fun2() Inside fun1()
Inside fun2()
Inside fun1() Inside fun2()
Compiler Error
Share your thoughts in the comments