Loading practice questions
What will be the output of the following C++ code
#include
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
Explanation:
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.