When I do something like
#include<iostream>
int main()
{
int x;
return 0;
}
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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.