Possible Duplicate:
Error on calling default constructor with empty set of brackets
Why does the following code compile without problems but when I switch the line
MCl<char, a> tryout;
to
MCl<char, a> tryout();
I receive "error C2228: left of '.ea' must have class/struct/union" ? Isn't tryout() a call to the default constructor?
Here's the full code
template <class T, T myval> class MCl
{
public:
T ea;
MCl() : ea(myval)
{
}
};
int main()
{
const char a = 'e';
MCl<char, a> tryout;
// MCl<char, a> tryout();
cout << tryout.ea;
return 0;
}