I get the following error with my code when I compile:
Undefined symbols for architecture x86_64:
"A::MyNumber", referenced from:
B::setValue(double) in B.o
ld: symbol(s) not found for architecture x86_64
In A
's header file:
public:
static double MyNumber;
In A
's class file, above the constructor outside of any functions:
double A::MyNumber = 1.0;
In B
's setValue()
function:
#include "A.h"
void B::setValue(double val)
{
double newVal = val * A::MyNumber;
...
}
I'm stumped...I looked at other examples in my project of using static variables and did my best to make sure I did it correctly. The only thing I can think of is that A
is in a library that is linked by B
's project.