What is the output of the following program? #include using namespace std; class TestClass { public: TestClass(int x) { cout << x << endl; } TestClass() { cout << "Hello!" << endl; } }; int main() { TestClass* test; return 0; }

Respuesta :

Answer:

An error will be occurred here. In C++ a function must be like

returntype function_name(){

}

but the functions in given class does not have returntype given. So there will be a syntax error.

If the returntype is defined then the code does not show any output since nothing is printed in the main function.