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{
A(){
cout<<"Constructor called";
}
};
int main(int argc, char const *argv[])
{
A a;
return}
Correct Answer: C — Error
No constructor should be made private because objects need to call them and as by default all the members of a class are private therefore constructor defined in the above program is private which is wrong therefore the compiler gives the error.