Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 791 Bytes

c26496.md

File metadata and controls

30 lines (23 loc) · 791 Bytes
title ms.date f1_keywords helpviewer_keywords description
Warning C26496
03/22/2018
C26496
USE_CONST_FOR_VARIABLE
C26496
CppCoreCheck rule C26496 that enforces C++ Core Guidelines Con.4

Warning C26496

The variable 'variable' is assigned only once, mark it as const.

See also

C++ Core Guidelines con.4.

Example

int GetTheNumber();
int GiveMeTheNumber(int);

void function1()
{
    int theNumber = GetTheNumber(); // C26496, 'theNumber' is never assigned to again, so it can be marked as const
    std::cout << theNumber << '\n';

    GiveMeTheNumber(theNumber);
    // ...
}