The best way to define any const is to write
const int m = 7;
const float pi = 3.1415926f;
const char x = 'F';
Usage #defineis bad C ++ style. Cannot be hidden #definein namespace scope.
Comparison
#define pi 3.1415926
from
namespace myscope {
const float pi = 3.1415926f;
}
The second way is obviously better.
source
share