help please

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fighterman19

    help please

    I want to ask about copy constructor.
    is the line sum=huge1.add(h uge2) will call the copy constructor?
    int main()
    {
    HUGE_INT huge1(0),huge2( 1), sum;

    sum=huge1.add(h uge2);

    //are these two line also a copy constructor?
    huge1.assign(hu ge2);
    huge2.assign(su m);

    return 0;

    };


  • Mike Wahler

    #2
    Re: help please

    "fighterman 19" <fighterman19@c omcast.net> wrote in message
    news:kPadnd-x1-8fTvaiU-KYgw@comcast.co m...[color=blue]
    > I want to ask about copy constructor.
    > is the line sum=huge1.add(h uge2) will call the copy constructor?[/color]

    We can't tell without seeing the definition of 'add()'.
    Does it take its argument by reference?
    [color=blue]
    > int main()
    > {
    > HUGE_INT huge1(0),huge2( 1), sum;
    >
    > sum=huge1.add(h uge2);
    >
    > //are these two line also a copy constructor?
    > huge1.assign(hu ge2);
    > huge2.assign(su m);[/color]

    We can't tell without seeing the definition of 'assign()'.
    Does it take its argument by reference?

    -Mike


    Comment

    • JustSomeGuy

      #3
      Re: help please

      have you tried putting trace code in the copy constructor of the class to
      see when it is called?
      Are you aware of the rule of three?

      "fighterman 19" <fighterman19@c omcast.net> wrote in message
      news:kPadnd-x1-8fTvaiU-KYgw@comcast.co m...[color=blue]
      > I want to ask about copy constructor.
      > is the line sum=huge1.add(h uge2) will call the copy constructor?
      > int main()
      > {
      > HUGE_INT huge1(0),huge2( 1), sum;
      >
      > sum=huge1.add(h uge2);
      >
      > //are these two line also a copy constructor?
      > huge1.assign(hu ge2);
      > huge2.assign(su m);
      >
      > return 0;
      >
      > };
      >
      >[/color]


      Comment

      • Kevin Goodsell

        #4
        Re: help please

        JustSomeGuy wrote:
        [color=blue]
        > have you tried...[/color]
        <snip>

        Please don't top-post. See section 5 of the FAQ for posting guidelines.



        -Kevin
        --
        My email address is valid, but changes periodically.
        To contact me please use the address from a recent posting.

        Comment

        Working...