警告 C26496
仅分配一次变量 “variable”,请将其标记为
const
。
另请参阅
示例
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);
// ...
}