Question:What will happen when the following code is compiled and executed?
#include<iostream> using namespace std; class myclass { private: int number; public: myclass() { number = 2; } int &a() { return number; } }; int main() { myclass m1,m2; m1.a() = 5; m2.a() = m1.a(); cout << m2.a(); return 0; }
A Compile time errors will be generated because right hand side of expressions cannot be functions
B The printed output will be 5
C The printed output will be 2
D The printed output will be undefined
+ AnswerB
+ Report