Here’s a basic struct (I hope)
struct SomeType {
float a;
float b;
float c;
float d;
SomeType(float, float, float, float);
};
And source
SomeType::SomeType(float na, float nb, float nc, float nd) : a(na), b(nb), c(nc), d(nd) {}
The I have a class
struct SomeClass {
static const SomeType v;
SomeClass();
};
When I then initialise it
const SomeType SomeClass::v(0,0,0,0);
My vales become inf or nan or -nan. Anyone seen this before, or know how to fix it?
Edit: Fixed type
Edit: This is quite close to my original example. I multiple classes with similar structure to SomeClass.
From what code are you seeing those incorrect values? If it’s from something like a constructor of another global variable, remember the static initialization order fiasco;
v‘s constructor might just not have run yet.Put an output statement in the
SomeTypeconstructor and check whether the output occurs before you see the incorrect values.