#include <algorithm>
#include <Windows.h>
int main()
{
int k = std::min(3, 4);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
什么是Windows正在做,如果我包括Windows.h我不能在Visual Studio 2005中使用std :: min.错误消息是:
error C2589: '(' : illegal token on right side of '::'
error C2059: syntax error : '::'
Run Code Online (Sandbox Code Playgroud) 当心,我在说::abs(),不是std::abs()
根据cplusplus.com网站,abs对于stdlib.h C版本应该表现不同,如果你包括<cmath>
以下是此页面的摘录(::abs不处理std::abs):
double abs (double x);
float abs (float x);
long double abs (long double x);
Compute absolute value
/*
Returns the absolute value of x: |x|.
These convenience abs overloads are exclusive of C++. In C, abs is only declared
in <cstdlib> (and operates on int values).
The additional overloads are provided in this header (<cmath>) for the integral types:
These overloads effectively …Run Code Online (Sandbox Code Playgroud)