Examveda

What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	int a;
 
   public:
	int assign(int i) const {
		a = i;
	}
	int return_value() const {
		return a;
	}
};
int main(int argc, char const *argv[])
{
	A obj;
	obj.assign(5);
	cout<<obj.return_value();
}

A. 5

B. 10

C. Error

D. Segmentation fault

Answer: Option C


Join The Discussion

Related Questions on Classes and Objects in C plus plus