-
inherit
hi,
I wirte a c++ program that I try to define very big number.
a function define
clsHugeInt clsHugeInt::operator + (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...
-
that operator is a member of the class, you can directly access all members of temp.
-
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::operator + (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);
}
-
what is the error? compile time? runtime?