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() {
}
}
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.
Do you mention the namespace anywhere? You need to write either:
using ophRuntime::LoggerStream;
const LoggerStream logger(L"Test Component");
or
using namespace ophRuntime;
const LoggerStream logger(L"Test Component");
or
const ophRuntime::LoggerStream logger(L"Test Component");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With