4.9k views
0 votes
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; }

1 Answer

6 votes

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.

User Javid Jamae
by
5.8k points