标题:写了个大数库, 大家看看效率,或者是否有bug
只看楼主
bccn250
Rank: 5Rank: 5
等 级:职业侠客
帖 子:154
专家分:379
注 册:2010-5-25
得分:0 
问个白痴的问题??

为什么那些 函数都用 friend ?有什么好处?
2010-06-07 13:39
forever74
Rank: 12Rank: 12Rank: 12
来 自:CC
等 级:贵宾
威 望:49
帖 子:1636
专家分:3940
注 册:2007-12-27
得分:0 
回复 7楼 Devil_W
精华啊,那是必须的。

对宇宙最严谨的描述应该就是宇宙其实是不严谨的
2010-06-07 16:03
Devil_W
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:9
帖 子:1160
专家分:1797
注 册:2009-9-14
得分:0 
以下是引用forever74在2010-6-7 16:03:25的发言:

精华啊,那是必须的。


可惜垃圾版主没看到。
2010-06-07 20:00
lijm1989
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:珠海
等 级:贵宾
威 望:12
帖 子:675
专家分:2844
注 册:2009-10-14
得分:0 
垃圾版主看到了~~可惜貌似暂时帮不了~~~
2010-06-08 10:29
南国利剑
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:29
帖 子:1165
专家分:3536
注 册:2010-4-12
得分:0 
路过。。。。爱莫能助。。。。

南国利剑
2010-06-08 13:46
xin310923
Rank: 5Rank: 5
等 级:职业侠客
威 望:1
帖 子:203
专家分:325
注 册:2009-12-22
得分:0 
主函数呢???我把你的代码复制下来在编译器上运行   发现没有主函数
2010-06-08 13:56
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
得分:0 
回复 9楼 BlueGuy
现在的精华帖还是需要申请的吗 ?

~~~~~~~~~~~~~~~好好学习~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2010-06-10 23:37
BlueGuy
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:29
帖 子:4476
专家分:4055
注 册:2009-4-18
得分:0 
回复 17楼 vfdff
不用, 版主可以自由操作,/

我就是真命天子,顺我者生,逆我者死!
2010-06-11 08:13
missiyou
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:531
专家分:218
注 册:2007-10-9
得分:0 
BigInt::BigInt(const BigInt &other)
{
    assert(this->dt.empty());
    dt=other.dt;
    sign=other.sign;
}

BigInt & BigInt::operator = (const BigInt & other)
{
    this->sign=other.sign;
    this->dt=other.dt;   
    return *this;
}
这二个有一个共同点, 如果说 this 和 &other  地址相等的话,我们是不用在去 执行
   this->sign=other.sign;
    this->dt=other.dt;   

我觉得  判断 this == &other  即使是新手,也会这么想的.
2010-06-11 12:56
Devil_W
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:9
帖 子:1160
专家分:1797
注 册:2009-9-14
得分:0 
以下是引用missiyou在2010-6-11 12:56:05的发言:

BigInt::BigInt(const BigInt &other)
{
    assert(this->dt.empty());
    dt=other.dt;
    sign=other.sign;
}

BigInt & BigInt::operator = (const BigInt & other)
{
    this->sign=other.sign;
    this->dt=other.dt;   
    return *this;
}
这二个有一个共同点, 如果说 this 和 &other  地址相等的话,我们是不用在去 执行
   this->sign=other.sign;
    this->dt=other.dt;   

我觉得  判断 this == &other  即使是新手,也会这么想的.



我觉得你应该看到传的参数是const类型。
如果this==&other, 再做=操作的时候或者拷贝构造的时候,肯定会出错的。
2010-06-11 13:01



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




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

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