fork download
  1. #include <vector>
  2.  
  3. struct A {
  4. void foo() {
  5. container.resize(2);
  6. container[0] = constant; // тут можно использовать
  7. container.push_back(constant); // а тут ошибка линковки
  8. }
  9.  
  10. std::vector<int> container;
  11. static const int constant;
  12. };
  13.  
  14. const int A::constant = 42;
  15.  
  16. int main(){
  17. A a;
  18. a.foo();
  19. }
  20.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty