ObjectiveMcq
Print Protected
This page is protected for print. Use the website to view the content.
What will be the output of the following C++ code
#include <iostream>
using namespace std;
class A{
public:
int a;
A(int a=0){
this->a = a;
}
};
int main(int argc, char const *argv[])
{
A aa2(10);
cout<<a2.a;
return}
Correct Answer: A — 010
As constructor is accepting default parameter therefore the declaration of a1 and a2 both are valid hence the program runs successfully.