LogiQuest
Back to Objects and Classes
2

What will be the output of the program?

#include <iostream>
using namespace std;
class P {
    int v;
public:
    P(int x) : v(x) {}
    friend int peek(const P &p);
};
int peek(const P &p) { return p.v; }
int main() { cout << peek(P(42)) << endl; return 0; }
Medium

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.