Examveda

What will be the output of the following C++ code?
#include <iostream>  
using namespace std;
class A{
public:
	int a;
	A(int a){
		this->a = a;
	}
};
int main(int argc, char const *argv[])
{
	A a1, a2(10);
	cout<<a2.a;
	return 0;
}

A. 10

B. Compile time error

C. Run-time error

D. No output

Answer: Option B


Join The Discussion

Related Questions on Constructors and Destructors in C plus plus