注册 登录
编程论坛 C++教室

Question about heap corruption --- see screen plot for details.

HJin 发布于 2007-07-05 18:47, 976 次点击

I was writing my BigInt class to compute 500! The class uses dynamically allocated array as interal data member.

I got an error about "heap", which you can see from the attached .jpg file, although my program does give the correct answer for 500!:


12201368259911100687012387854230469262535743428031928421924135883858453731538819
97605496447502203281863013616477148203584163378722078177200480785205159329285477
90757193933060377296085908627042917454788242491272634430567017327076946106280231
04526442188787894657547771498634943677810376442740338273653974713864778784954384
89595537537990423241061271326984327745715546309977202781014561081188373709531016
35632443298702956389662891165897476957208792692887128178007026517450776841071962
43903943225364226052349458501299185715012487069615681416253590566934238130088562
49246891564126775654481886506593847951775360894005745238940335798476363944905313
06232374906644504882466507594673586207463792518420045936969298102226397195259719
09452178233317569345815085523328207628200234026269078983424517120062077146409794
56116127629145951237229913340169552363850942885592018727433795173014586357570828
35578015873543276888868012039988238470215146760544540766353598417443048012893831
38968816394874696588175045069263653381750554781286400000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000
Press any key to continue . . .


If you could help about the heap problem, I would be very much appreciated.

HJin

只有本站会员才能查看附件,请 登录

4 回复
#2
aipb20072007-07-05 20:53
不懂,HJin大哥把你代码弄出来,让我们好研究研究。

(*_*)
#3
HJin2007-07-05 21:18
almost there --- will release soon. I think it would be a very good practice for a beginner (not you) to learn operator overloading.

I've overloaded almost 20 operators.

#4
aipb20072007-07-05 21:45
呵呵,20个,这么多啊!
那你加油吧!!!

》_《
#5
野比2007-07-05 22:06
哈... HJin开始弄你的BigNumber拉... 不是做1000!吗?... 变拉?
1