Sorry,
I know this question has been asked many a time but what is the "standard" work around for defining a consts (and const arrays) in a C++ class??? That is, is there a nice way of doing it? What's the best and most readable way of doing it?

it's horrible:

Qt Code:
  1. class MyClass
  2. {
  3.  
  4. const int arraySize = 3;//won't work
  5. const int arr[3] = {1, 2, 3}; //won't work
  6.  
  7. enum{
  8. arraySize = 3;
  9. };
  10. //but I still can't ...
  11. const int arr[arraySize] = {1, 2, 3};
  12.  
  13. //see, I've got stuff that's really natural in a class definition - rather than implementation
  14. //thus:
  15. enum RANGE {
  16. _OPEN = 0,
  17. _2R,
  18. _20R,
  19. _200R,
  20. _2K,
  21. _20K,
  22. _200K,
  23. _2M
  24. };
  25. const double _RAN[_2M+1] = {
  26. 0,
  27. 2,
  28. 20,
  29. 200,
  30. 2000,
  31. 20000,
  32. 200000,
  33. 2000000
  34. };
  35. //so that in my code I can say things like setRange(_RAN[_2M]);
  36. }
To copy to clipboard, switch view to plain text mode 

thanks
Kev