chm*_*ike 5 c++ static class-variables
我有一个带有常量静态变量a的基类A. 我需要B类的实例对静态变量a有不同的值.如何实现这一点,最好是使用静态初始化?
class A {
public:
static const int a;
};
const int A::a = 1;
class B : public A {
// ???
// How to set *a* to a value specific to instances of class B ?
};
Run Code Online (Sandbox Code Playgroud)