In my header I have a public static const declared and I define in the source file as a class member. I want to define it in the source file because I am including and using a constant from an it, and I don't want to include in my header.
If I use static constexpr in the header it requires a definition there.
header
public:
static const double DEG_TO_RADIANS;
source
#include <math.h>
const double MyClass::DEG_TO_RADIANS = (M_PI/180.0);
Is this a situation where you just can't use constexpr, does this matter at all?
Why does a static const allow me to not define the variable but static constexpr doesn't?
Aucun commentaire:
Enregistrer un commentaire