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
  • 4,769
  • 1
  • 28
  • 34

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
  • 57,408
  • 33
  • 153
  • 271