Results 1 to 4 of 4

Thread: inherit

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    13

    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...

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    13
    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);
    }

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width