C26496 USE_CONST_FOR_VARIABLEC26496 USE_CONST_FOR_VARIABLE

'Variable' 변수는 한 번만 할당 되며로 표시 const 합니다.The variable 'variable' is assigned only once, mark it as const.

추가 정보See also

C++ Core Guidelines con. 4.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);
    // ...
}