因为要调用别人写的一些结构函数,在自己工程中添加了对应的a.cpp和a.h文件(非封装类,普通文件),里面包含max()和min()函数,结果包含对应头文件后出现如题的错误:
error C3861: “max”: 找不到标识符;
解决办法:
1、在添加的a.h文件中#define了max和min函数,编译出现max、min重定义错误,(因为系统默认头文件windef.h中也定义了相应函数,造成重定义)
2、在a.h中包含windef.h,提示windef.h中有些莫名其妙的错误,因为是系统文件确认应该这样添加应该是错误的
#include "stdafx.h"
#include
using namespace std;
long fac(int n) //阶乘通常比较大,所以可以用long int 类型做返回值
{
long ret=1;
for(int i=2;i<=n;i++)
{
ret=ret*i; //不断地累乘
}
return ret;
}
void main()
{
int n ;
cout<<"please input a number n to calculate n!:";
cin>>n;
cout<}
fac是什么?
另外标准库函数iostream的包含最好用尖括号