共用方式為


警告 C26496

變數 ' variable ' 只會指派一次,將其標示為 const

另請參閱

C++ 核心指導方針 con.4

範例

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