Redigera

Dela via


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);
    // ...
}