|
-
Mar 18th, 2002, 05:25 PM
#1
Thread Starter
New Member
inherit
hi,
I wirte a c++ program that I try to define very big number.
a function define
clsHugeInt clsHugeInt: perator + (const clsHugeInt &operand2) const {
clsHugeInt temp(size);
..........
I create a variable temp(size); which is size is "size" I need to use this temp variable's private variable which is firstptr.
how can I do this (if it is posible I dont get firstptr to public ).....
thanks a lot...
yilmaz...
-
Mar 19th, 2002, 10:54 AM
#2
that operator is a member of the class, you can directly access all members of temp.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Mar 21st, 2002, 09:54 AM
#3
Thread Starter
New Member
hi
probably I explain somthing wrong I sent you whole code but it is not work ....
/*
description: add two hugeInt
input : hugeInt1,hugeInt2
output: hugeInt1+hugeInt2
*/
clsHugeInt clsHugeInt: perator + (const clsHugeInt &operand2) const {
clsHugeInt result(size);
myhugeInt *resultTempPtr,*rightTempPtr,*leftTempPtr;
unsigned int i,carry,temp;
carry=0;
// set the temp variables
resultTempPtr = result.firstPtr;
rightTempPtr = (&operand2)->firstPtr;
leftTempPtr = this->firstPtr;
for (i=0;i<size;i++){// for each int part
if (carry==0)
resultTempPtr->number = Add ( leftTempPtr->number , rightTempPtr->number , &carry);
else{
resultTempPtr->number = Add ( leftTempPtr->number ,rightTempPtr->number , &carry);
resultTempPtr->number = Add ( resultTempPtr->number ,1,&temp);
if (temp==1) carry=1;
}
//move next
if (resultTempPtr!=NULL)//check if problem for moving
resultTempPtr=resultTempPtr->nextPtr;
if (rightTempPtr!=NULL)
rightTempPtr=rightTempPtr->nextPtr;
if (leftTempPtr!=NULL)
leftTempPtr=leftTempPtr->nextPtr;
}
return (result);
}
-
Mar 21st, 2002, 12:20 PM
#4
what is the error? compile time? runtime?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|