Class Specific #define
-
Hello all. I'd like to use something that approximates a Class Specific #define without using namespaces, static const's or enums. Actually enums in the class would be good except some of the defines are floating point numbers. 1 header file has #define MAX_LASER_POWER 23.3, another has #define MAX_LASER_POWER 44.0 Anybody have a clever way to elegantly encapsolate these defines? Thanks in advance!
-
Hello all. I'd like to use something that approximates a Class Specific #define without using namespaces, static const's or enums. Actually enums in the class would be good except some of the defines are floating point numbers. 1 header file has #define MAX_LASER_POWER 23.3, another has #define MAX_LASER_POWER 44.0 Anybody have a clever way to elegantly encapsolate these defines? Thanks in advance!
Well, you could try this:
class A
{
public:
static const double MAX_LASER_POWER;
};[EDIT] Oops, I forgot the "const".
// In A's source file:
const double A::MAX_LASER_POWER = 23.3;class B
{
public:
static const double MAX_LASER_POWER;
};[EDIT] Oops, I forgot the "const".
// In B's source file:
const double B::MAX_LASER_POWER = 44.0;You will get basically the same results as using a #define since they are const. Chris Richardson Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith