为什么我会收到“未引用的局部变量"?警告? (C ++) [英] Why do I get an "Unreferenced Local Variable" warning? (C++)
本文介绍了为什么我会收到“未引用的局部变量"?警告? (C ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我做类似的事情
#include<iostream>
int main()
{
int x;
return 0;
}
我收到有关x是未引用的局部变量的警告(我假设是因为我创建了一个变量,然后未使用它),为什么这会给我警告?
I get a warning about x being an unreferenced local variable (I assume becuase I created a variable, then did not use it), why does this give me a warning though?
推荐答案
可能是因为您无所事事地浪费了内存.
Probably because you're wasting memory for nothing.
此外,代码变得肮脏且难以理解,更不用说程序员通常不会定义他们不需要的变量,所以这有点像这真的是您的意思吗?"警告.
Besides, the code becomes dirty and harder to understand, not to mention that programmers don't usually define variables they don't need, so it's sort of a "is this really what you meant?" warning.
这篇关于为什么我会收到“未引用的局部变量"?警告? (C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文