When compiling this c++ code, I get an error on the last line.
#include <iostream>
class TestClass {
public:
TestClass(int val)
: value(val)
{
}
int getValue()
{
return value;
}
private:
int value;
};
int main()
{
TestClass b();
std::cout << b.getValue() << std::endl;
}
The compiler (gcc on Ubuntu 14.04) complains:
error: "request for member ‘getValue’ in ‘b’, which is of non-class type ‘TestClass()’"
Now my question is: What exactly does b
contain? The compiler doesn't complain about TestClass b()
.