可能重複使用:
What is the purpose of the statement 「(void)c;」?是什麼`(無效)的D'
class ArgString : public Arg::Base
{
public:
...
bool CanConvertToInt() const
{
const char *cstr = mValue.c_str();
char *result = 0;
long d = strtol(cstr, &result, 10);
(void) d; // what is the usage of this line?
return result != cstr;
}
private:
std::string mValue;
};
誰能告訴我下面的行的目的是什麼?
(void) d;
謝謝
// //更新
正如一些人指出,該行的目的是抑制編譯警告。對我來說,這很奇怪。因爲這是非常嚴重的警告
warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use
_CRT_SECURE_NO_WARNINGS. See online help for details.
爲什麼我們忽略這個大的警告,並只處理較小的警告。
我不知道目的是什麼,但它恕我直言,聲明不產生任何效果;-) – emesx 2011-12-13 16:59:05
請注意,這是你有控制權的代碼,請評論答案後。 – 111111 2011-12-13 16:59:35