หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
'member' : static data member cannot be initialized via derived class
Remarks
The initialization of a static data member was ill formed. The compiler accepted the initialization. To avoid the warning, initialize the member through the base class.
Use the warning pragma to suppress this warning.
Example
The following example generates C4356:
// C4356.cpp
// compile with: /W2 /EHsc
#include <iostream>
template <class T>
class C {
static int n;
};
class D : C<int> {};
int D::n = 0; // C4356
// try the following line instead
// int C<int>::n = 0;
class A {
public:
static int n;
};
class B : public A {};
int B::n = 10; // C4356
// try the following line instead
// int A::n = 99;
int main() {
using namespace std;
cout << B::n << endl;
}