R
Rune Allnor
Hi folks.
I naively tried to define some useful constants inside a namespace:
namespace me{
#define PI = 3.14;
};
It works when I refer to the constant from within that namespace,
but from the outside I get compiler errors:
float a= me:
I * 28;
One obvious solution is to define the constant in the global
namespace, but I would prefer not to. So I tried a simple
static variable:
namespace me{
template<class T>
static const T Pi = 3.14;
};
but that, too, gives a compiler error.
So how does one solve this simple task?
Rune
I naively tried to define some useful constants inside a namespace:
namespace me{
#define PI = 3.14;
};
It works when I refer to the constant from within that namespace,
but from the outside I get compiler errors:
float a= me:
One obvious solution is to define the constant in the global
namespace, but I would prefer not to. So I tried a simple
static variable:
namespace me{
template<class T>
static const T Pi = 3.14;
};
but that, too, gives a compiler error.
So how does one solve this simple task?
Rune