What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class A
{
int a;
A() { a = 5;}
};
int main()
{
A *obj = new A;
cout << obj->a;
}
#include <iostream>
using namespace std;
class A
{
int a;
A() { a = 5;}
};
int main()
{
A *obj = new A;
cout << obj->a;
}A. 5
B. Garbage value
C. Compile-time error
D. Run-time error
Answer: Option C

Join The Discussion