错误提示是什么意思呵,,谢谢了呀

来源:百度知道 编辑:UC知道 时间:2024/06/01 23:40:46
#include<iostream.h>
int add(int,int);
void main()
{
int a,b;
cout<<"Enter a b:";
cin>>a>>b;
int c=add(a,b);
cout<<"a+b="<<c<<endl;
}
int add(intx,inty)
{
return x+y;
}

--------------------Configuration: Cpp2 - Win32 Debug--------------------
Compiling...
Cpp2.cpp
c:\documents and settings\wm1\my documents\c++\cpp2.cpp(4) : error C2143: syntax error : missing ')' before '{'
c:\documents and settings\wm1\my documents\c++\cpp2.cpp(4) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
c:\documents and settings\wm1\my documents\c++\cpp2.cpp(11) : error C2065: 'intx' : undeclared identifier
c:\documents and settings\wm1\my documents\c++\cpp2.cpp(11) : error C2065:

你的代码没什么问题,只是最后的函数的形参定义少了空格。
int add(int x,int y)
{
return x+y;
}

c:\documents and settings\wm1\my documents\c++\cpp2.cpp(11) : error C2065: 'intx' : undeclared identifier
在文件的第11行,intx没有定义。你应该写成int x

c:\documents and settings\wm1\my documents\c++\cpp2.cpp(11) : error C2065: 'inty' : undeclared identifier
在文件的第11行,inty没有定义。你应该写成int y

c:\documents and settings\wm1\my documents\c++\cpp2.cpp(4) : error C2143: syntax error : missing ')' before '{'
在文件第4行,结构错误,在"{"前缺少了")"。我运行时没有这个

c:\documents and settings\wm1\my documents\c++\cpp2.cpp(4) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
c:\documents and settings\wm1\my documents\c++\cpp2.cpp(12) : error C2448: '<Unknown>' : funct