1

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"
    ...
Community
  • 1
  • 1
Joseph King
  • 5,089
  • 1
  • 30
  • 37

1 Answers1

3

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.

djechlin
  • 59,258
  • 35
  • 162
  • 290