C++ Error: Expected a type specifier

You can’t construct class members like this:-

  struct TestComponent::TestComponentImpl 
  {

  private:
        LoggerStream logger(L"Test Component");

Instead, use an initialization list in the constuctor, like this:

struct TestComponent::TestComponentImpl 
{
   LoggerStream logger;

    TestComponent::TestComponent() : impl(new TestComponentImpl()),
                                     logger("L"Test Component")
    {   
    }

    ...    
}

And I think you’ve fallen foul of the “Most Vexing Parse” because the compiler thinks logger must be a function, and it’s complaining that L"Test Component" is not a type specifier for a parameter.

Leave a Comment