Vidyalelo
C++ Programming · Q58

Constructors and Destructors in C++

Programming · C++ Programming · question 58

Q58

What will be the output of the following C++ code? #include 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
Answer
C.
Run-time error
D.
No output

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board