标题:请指出错误
取消只看楼主
lw8484654
Rank: 1
等 级:新手上路
帖 子:223
专家分:0
注 册:2005-12-1
 问题点数:0 回复次数:1 
请指出错误
class Foo
{
public:explicit Foo(ing arg){......}
};
void g(Foo f){.....}
int main()
{
Foo f1;
g(f1);
g(-999);
return 0;
}
我觉得是g(f1);错了,是不是呢?因为这个构造函数是一个转型构造函数
搜索更多相关主题的帖子: public return 
2006-05-31 20:50
lw8484654
Rank: 1
等 级:新手上路
帖 子:223
专家分:0
注 册:2005-12-1
得分:0 
#include<iostream.h>
class Foo
{
public:
explicit Foo(int arg){n=arg;}
void print(){cout<<n<<endl;}
private:
int n;
};
void g(Foo f)
{
f.print();
}
int main()
{
Foo f1;
g(f1);
g(-888);
return 0;
}
我把程序补全了,程序在Foo f1;g(-888);这两行都报错了,为什么呢?
请教
2006-05-31 22:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-68883-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.279854 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved