I have a .h
file which contains class definition and an extern
definition of a static variable
The accompanying .cpp
file declares and initializes this variable.
But when I try you access this variable in my main.cpp
I get a does not name a type
error.
What am I doing wrong?
Contents of test.h
file:
#pragma once
namespace Mine {
class Test {
...
};
} // namespace
extern Mine::Test* variable;
Contents of test.cpp
file:
Mine::Test* variable = nullptr;
Contents of main.cpp
:
#include "test.h"
variable = new Mine::Test();