LogiQuest
Back to Objects and Classes
8

What will be the output of the program?

#include <iostream>
using namespace std;
class C {
public:
    static int n;
    C() { n += 2; }
};
int C::n = 1;
int main() {
    C a, b;
    cout << C::n << endl;
    return 0;
}
Medium

Discussion (0)

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

Log in to join the discussion.