C
Christopher
Where is the proper place to assign the value to a public static const
variable that is a member of a class?
My compiler is angry with me, but I don't understand why. It doesn't
mind any other static consts that I have declared in the same manner.
// x.h
class X
{
public:
static const double TESTER1 = 0.1;
static const double TESTER2 = 0.2;
X(const SomeClass & rhs);
};
// x.cpp
#include "x.h"
X::X(const SomeClass & rhs)
{
int g = TESTER1;
int h = TESTER2;
}
Compiler complains about undefined referance to TESTER2 when the copy
constuctor is called from another library that is dependant on the
library that contains class X.
variable that is a member of a class?
My compiler is angry with me, but I don't understand why. It doesn't
mind any other static consts that I have declared in the same manner.
// x.h
class X
{
public:
static const double TESTER1 = 0.1;
static const double TESTER2 = 0.2;
X(const SomeClass & rhs);
};
// x.cpp
#include "x.h"
X::X(const SomeClass & rhs)
{
int g = TESTER1;
int h = TESTER2;
}
Compiler complains about undefined referance to TESTER2 when the copy
constuctor is called from another library that is dependant on the
library that contains class X.