请各位朋友帮我看一下,我是刚学C++的

来源:百度知道 编辑:UC知道 时间:2024/06/08 20:31:46
刚开始学,遇到问题,不知道怎么回事。代码是照书直搬的,代码如下:
#include <iostream>
int Add (int first,int second)
{
std::cout<<"In Add(),received"<<first<<" and "<<second<<"\n\";
return (first+second);
}

int main()
{
using std::cout;
using std::cin;
cout<<"I'm in main()!\n";
int a,b,c;
cout<<"Enter two numbers:";
cin>>a;
cin>>b;
cout<<"\nCalling Add()\n";
c=Add(a,b);
cout<<"\nBack in main().\n"
cout<<"c was set to"<<c;
cout<<"\nExiting...\n\n";
return 0;
}

我用dev C++ 4.9.9.2 编译时出错,错误代码如下:

5 expected primary-expression before "return"
5 expected `;' before "return"

#include <iostream>
using namespace std;

int Add (int first,int second)
{
cout<<"In Add(),received"<<first<<" and "<<second<<"\n";//这里最后本来是"\n\",‘"’被你转义了。
return (first+second);
}

int main()
{
cout<<"I'm in main()!\n";
int a,b,c;
cout<<"Enter two numbers:";
cin>>a;
cin>>b;
cout<<"\nCalling Add()\n";
c=Add(a,b);
cout<<"\nBack in main().\n";//少了分号
cout<<"c was set to"<<c;
cout<<"\nExiting...\n\n";
return 0;
}

cout<<"\nBack in main().\n"
后面没有;

#include <iostream>
int Add (int first,int second)
{
cout<<"In Add(),received"<<first<<&qu