Possible Duplicate:
Default constructor with empty brackets
Can anyone explain why I get a compile error for the following code?
CString CDiagram::GetFormattedMessage()
{
CString strFormat();
strFormat = "Warning : %s"
...
Possible Duplicate:
Default constructor with empty brackets
Can anyone explain why I get a compile error for the following code?
CString CDiagram::GetFormattedMessage()
{
CString strFormat();
strFormat = "Warning : %s"
...
You declared a function strFormat
that returns type CString
. Whoops. Google "C++ most vexing parse" for more literature. Correct syntax is
CString strFormat;
Which does explicitly call the default constructor, unlike, say, in Java, where this would just declare a null variable without instantiating it.