C++ Error: Expected a type specifier
c++
Solution
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.
Problem
When I try to use a `LoggerStream` like this, I get 'expected a type specifier': `const LoggerStream logger(L"Test Component");` Here's where I'm trying to use the `LoggerStream`: ``` #include "Logger.h" #include "TestComponent.h" namespace ophRuntime { struct TestComponent::TestComponentImpl { private: LoggerStream logger(L"Test Component"); NO_COPY_OR_ASSIGN(TestComponentImpl); }; TestComponent::TestComponent() : impl(new TestComponentImpl()) { } bool TestComponent::Init() { } } ```