| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付买域名,送MP3、MP4
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY买空间,免费送域名(厦门中资源)
共有 463 人关注过本帖
标题:哪里错了?
收藏  订阅  推荐  打印 
xianshizhe111
Rank: 6Rank: 6
等级:金牌会员
帖子:1451
积分:15818
注册:2007-12-8

#include <iostream>
using namespace std;
inline int add(int x,int y){return x+y;}
int main ()
{
    int a,b,c;
    cin>>a>>b;
    c=add(a,b);
    cout<<"add(a+b)="<<c<<endl;
    return 0;
}
2008-9-17 11:59
zzt_428
Rank: 2
来自:南京师范大学
等级:注册会员
威望:1
帖子:156
积分:1740
注册:2008-7-6
回答

哪个告诉你不能返回函数中定义的变量的?我劈死他......
是不能返回函数中定义的对象的引用或指针.
要是不能返回,,那把参数传给函数,不肉包子打狗有去无回吗?

学习切忌浮躁.
2008-9-17 18:59
Emmahan
Rank: 1
等级:新手上路
帖子:6
积分:152
注册:2008-9-19
回复 11# xianshizhe111 的帖子

inline int add(int x,int y){return x+y;} 这个是叫内联函数吧?
不是说内联函数要放到头文件吗?
2008-9-19 17:15
baidiao
Rank: 1
等级:新手上路
帖子:17
积分:308
注册:2008-9-9
还可以这样写

#include <iostream>
using namespace std;

int add (int x,int y);

int main ()
{
    int a,b,c;
    cin>>a>>b;
    c=add(a,b);
    cout<<"add(a+b)="<<c<<endl;
    return 0;
}

int add(int x,int y)
{
    int z;
    z=x+y;
    return z;
}
2008-9-19 18:13
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.050120 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved