Advertisement
karlicoss

Static const members

Jun 16th, 2011
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. //sample1.cpp. Здесь все ок
  2. struct Foo
  3. {
  4.     static const int a = 10;
  5. };
  6. int main
  7. {
  8.     Foo foo;
  9.     return 0;
  10. }
  11. //sample2.cpp.
  12. struct Bar
  13. {
  14.     static const int a[] = {1, 2, 3};//так нельзя
  15. };
  16. //sample3.cpp
  17. struct BarFixed
  18. {
  19.     static const int a[];
  20. };
  21. const int BarFixed::a[] = {1, 2, 3};//так можно
  22. //Вопрос - почему можно инициализировать static const int внутри класса, а static const int[] - нельзя?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement