LogiQuest
Back to Constructors and Destructors
15

What will be the output of the program?

#include <iostream>
using namespace std;
class C {
public:
    int v;
    C(int x) : v(x) {}
    C(const C &o) : v(o.v * 10) {}
};
int main() {
    C a(3);
    C b = a;
    cout << b.v << endl;
    return 0;
}
Medium

Discussion (0)

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

Log in to join the discussion.