Here is my code
#include
using namespace std;
class MyTestClass
{
int MyTestIVar;
public:
MyTestClass(void);
int
You have stumbled upon the most vexing parse.
The line
MyTestClass mTC();
is parsed as a function prototype of a function named mTC
which has no arguments and returns an instance of MyTestClass
.
MyTestClass mTC();
Does not declare an object of the MyTestClass
class, as you think.
It Actually, declares a function by the name of mTC
which does not take any parameters and returns an MyTestClass
object.
This is known as the Most Vexing Parse in c++.