C26495 MEMBER_UNINIT
Variable 'identifier' is uninitialized. Always initialize a member variable (type.6).
Remarks
A member variable isn't initialized by a constructor or by an initializer. Make sure all variables are initialized by the end of construction. For more information, see C++ Core Guidelines Type.6 and C.48.
Example
struct MyStruct
{
int value;
MyStruct() {} // C26495, MyStruct::value is uninitialized
};
To fix the warning, add in-class initialization to all of the member variables:
struct MyStruct
{
int value{};
MyStruct() {} // no warning, MyStruct::value is set via default member initialization
};
Maklum balas
Kirim dan lihat maklum balas untuk