| title | C26495 | |
|---|---|---|
| ms.date | 03/22/2018 | |
| ms.topic | reference | |
| f1_keywords |
|
|
| helpviewer_keywords |
|
|
| description | CppCoreCheck rule that enforces C++ Core Guidelines Type.6 |
Variable '%variable%' is uninitialized. Always initialize a member variable (type.6).
C++ Core Guidelines Type.6 and C.48
struct MyStruct
{
int value;
MyStruct() {}; // C26495, MyStruct::value is uninitialized
};To fix the warning, add in-class initializers to all of the member variables. See the above linked C++ Core Guidelines pages for additional information.
struct MyStruct
{
int value{};
MyStruct() {}; // no warning, MyStruct::value is set via default member initialization
};