弱弱的问题,关于algorithm库中max函数的使用
// max example
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
cout << "max(1,2)==" << max(1,2) << endl;
cout << "max(2,1)==" << max(2,1) << endl;
cout << "max('a','z')==" << max('a','z') << endl;
cout << "max(3.14,2.73)==" << max(3.14,2.73) << endl;
return 0;
}
出现如下错误信息:
error C2065: 'max' : undeclared identifier
这是cplusplus中的范例代码,为什么会出错呢?
[解决办法]
你用什么编译器搞得?VS 2005没错
[解决办法]
看看math.h以及stdlib.h这两个头文件是否提供了max函数吧
[解决办法]
vs 2008也没错
[解决办法]