I have 2 files:
tier1.h
tier1.cpp
In tier1.h I have:
//code
namespace variab
{
int x...; float tpl...; //etc
}
namespace universal
{
using namespace variab;
//some functions prototypes
}
In tier1.cpp there are the functions defined. Some of the functions are in imbricated namespaces, like: universal::extG::. These functions are using the variables found in variab namespace.
In the source file, where main is to be found, tier1.h is included.
When I try to compile the program, it gives me errors pointing to the variables found in variab namespace. The error is the same everywhere. This is how it looks:
error LNK2001: unresolved external symbol "int * variab::st" (?st@variab@@3PAHA)
Where is the problem?
In the header file you're declaring the variables in the namespace. You need to only declare them with the extern
keyword:
namespace variab
{
extern int x;
extern float tpl;
// etc...
}
Then in a source file you do the definition:
namespace variab
{
int x;
float tpl;
// etc...
}