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;
}
Correct Answer: The printed output will be 5
Explanation:
Note: This Question is unanswered, help us to find answer for this one
More C++ MCQ Questions