class A {
  static int foo () {} // ok
  static int x; // <--- needed to be defined separately in .cpp file
};

I don't see a need of having A::x defined separately in a .cpp file (or same file for templates). Why can't be A::x declared and defined at the same time?

Has it been forbidden for historical reasons?

My main question is, will it affect any functionality if static data members were declared/defined at the same time (same as Java) ?

没有正确的解决方案

许可以下: CC-BY-SA归因
scroll top