问个VC 的超白痴问题
来源:百度知道 编辑:UC知道 时间:2024/05/22 08:32:46
初学者 写了一段最简单的代码:
#include "stdafx.h"
int main(int argc, char* argv[])
{
int aa=hh(3);
return 0;
}
int hh(int a)
{
return a+1;
}
结果出错
error C2065:“hh” undeclared identifier
error C2373:“hh” redefinition; different type modifiers
求解 谢谢
#include "stdafx.h"
int main(int argc, char* argv[])
{
int aa=hh(3);
return 0;
}
int hh(int a)
{
return a+1;
}
结果出错
error C2065:“hh” undeclared identifier
error C2373:“hh” redefinition; different type modifiers
求解 谢谢
C语言是顺序编译的.必须要声明,后使用.所以要么你把函数hh写到main上面,要么就在main上面声明也可以.
把hh的定义放在main前面。
或者在main里加上int hh(int);
在int aa=hh(3); 前面加一句int hh(int);就行了。使用函数前要先声明。