नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'identifier': unreferenced local variable
Remarks
The local variable is never used.
Examples
This warning occurs in the obvious situation:
// C4101a.cpp
// compile with: /W3
int main() {
int i; // C4101
}
However, this warning also occurs when calling a static member function through an instance of the class:
// C4101b.cpp
// compile with: /W3
struct S {
static int func()
{
return 1;
}
};
int main() {
S si; // C4101, si is never used
int y = si.func();
return y;
}
In this situation, the compiler uses information about si to access the static function, but the instance of the class isn't needed to call the static function; hence the warning. To resolve this warning, you could:
Add a constructor, in which the compiler would use the instance of
siin the call tofunc.Remove the
statickeyword from the definition offunc.Call the
staticfunction explicitly:int y = S::func();.