函数调用问题
#include<iostream>intadd(intfirst,intsecond){std::cout<<"inadd(),receivd"<<first<<"an...
#include<iostream>
int add(int first,int second)
{
std::cout<<"in add(),receivd"<<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;
}
这里不用给a,b赋值吗?比如a=first,b=second;
c=add(a,b)就把上边的(first,second)调用到main里了吗? 展开
int add(int first,int second)
{
std::cout<<"in add(),receivd"<<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;
}
这里不用给a,b赋值吗?比如a=first,b=second;
c=add(a,b)就把上边的(first,second)调用到main里了吗? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询