B
brekehan
I am embaressed to ask such a newbie question, but hey, we all forget
things. If I want to define some constants within a namespace and
share those constants with multiple cpp files. What is the correct way
to do so?
I was under the impression I could:
// one.h
namespace somespace
{
const double tester = 0.0;
}
class SomeClass
{
//etc etc
};
// one.cpp
#include "one.h"
int main ()
{
int x = somespace::tester;
return 0;
}
// two.cpp
#include "one.h"
int y = somespace::tester;
However, I was told that when linked this compiler will effectively
make two copies of the variable tester, one for each module. What is
the correct way to use constants in a large prject?
things. If I want to define some constants within a namespace and
share those constants with multiple cpp files. What is the correct way
to do so?
I was under the impression I could:
// one.h
namespace somespace
{
const double tester = 0.0;
}
class SomeClass
{
//etc etc
};
// one.cpp
#include "one.h"
int main ()
{
int x = somespace::tester;
return 0;
}
// two.cpp
#include "one.h"
int y = somespace::tester;
However, I was told that when linked this compiler will effectively
make two copies of the variable tester, one for each module. What is
the correct way to use constants in a large prject?