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:
A(){
cout<<"Constructor called";
}
};
int main(int argc, char const *argv[])
{
A *a;
return}
Correct Answer: A — Nothing printed
As we have declared a pointer variable for class A but we have not initialized the memory to that pointer and until the memory is not initialized the constructor for the pointer variable will not be called hence nothing is printed on the screen.