Basic C++ questions

Discussion in 'C++' started by webfan, Sep 28, 2006.

  1. webfan

    webfan Guest

    1. How many types of copy constructor in C++?

    2. Will compiler-generated copy constructor do bitwise or memberwise
    copying?
     
    webfan, Sep 28, 2006
    #1
    1. Advertising

  2. webfan

    Phlip Guest

    webfan wrote:

    > 1. How many types of copy constructor in C++?
    >
    > 2. Will compiler-generated copy constructor do bitwise or memberwise
    > copying?


    Guessing from 2, the answer to 1 is "compiler-generated or
    programmer-supplied."

    The answer to 2 is "memberwise".

    Is this for a quiz or something?

    --
    Phlip
    http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
     
    Phlip, Sep 28, 2006
    #2
    1. Advertising

  3. webfan wrote:
    > 1. How many types of copy constructor in C++?


    If you refer to possible signatures, then two.

    > 2. Will compiler-generated copy constructor do bitwise or memberwise
    > copying?


    The latter. What book are you reading that doesn't explain those
    basic elements of the language?

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Sep 28, 2006
    #3

  4. > 1. How many types of copy constructor in C++?
    >
    > 2. Will compiler-generated copy constructor do bitwise or memberwise
    > copying?


    Is homework of you?
     
    Gernot Frisch, Sep 29, 2006
    #4
  5. webfan

    Ron Natalie Guest

    Victor Bazarov wrote:
    > webfan wrote:
    >> 1. How many types of copy constructor in C++?

    >
    > If you refer to possible signatures, then two.


    Actually, it can be more. You can have defaulted
    args for the other parameters.

    >
    >> 2. Will compiler-generated copy constructor do bitwise or memberwise
    >> copying?

    >
    > The latter. What book are you reading that doesn't explain those
    > basic elements of the language?
    >

    Nothing trully works "bitwise" in C++. The smallest unit of
    operation is a byte.
     
    Ron Natalie, Sep 29, 2006
    #5
  6. Ron Natalie wrote:
    > Victor Bazarov wrote:
    >> webfan wrote:
    >>> 1. How many types of copy constructor in C++?

    >>
    >> If you refer to possible signatures, then two.

    >
    > Actually, it can be more. You can have defaulted
    > args for the other parameters.
    >
    >>
    >>> 2. Will compiler-generated copy constructor do bitwise or memberwise
    >>> copying?

    >>
    >> The latter. What book are you reading that doesn't explain those
    >> basic elements of the language?
    >>

    > Nothing trully works "bitwise" in C++. The smallest unit of
    > operation is a byte.


    I think & and | and ^ operators work bitwise in C++. That's why they
    are called bitwise.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Sep 29, 2006
    #6
  7. webfan

    Ron Natalie Guest


    >>>

    >> Nothing trully works "bitwise" in C++. The smallest unit of
    >> operation is a byte.

    >
    > I think & and | and ^ operators work bitwise in C++. That's why they
    > are called bitwise.
    >


    But they work on something no smaller than a char.

    Actually, with bitfields you can get to smaller items than a char,
    but in general bytes are the smallest entity.
     
    Ron Natalie, Sep 29, 2006
    #7
  8. webfan

    Kai-Uwe Bux Guest

    Ron Natalie wrote:

    > Victor Bazarov wrote:
    >> webfan wrote:

    [snip]
    >>> 2. Will compiler-generated copy constructor do bitwise or memberwise
    >>> copying?

    >>
    >> The latter. What book are you reading that doesn't explain those
    >> basic elements of the language?
    >>

    > Nothing trully works "bitwise" in C++. The smallest unit of
    > operation is a byte.


    I think, under the as-if rule, an implementation is allowed to copy,say, a
    char or an unsigned int bitwise as long as it makes sure that at the end,
    all bits have been copied :)


    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Sep 29, 2006
    #8
  9. webfan

    Someone Guest

    Ron Natalie wrote:
    >
    >>>>
    >>> Nothing trully works "bitwise" in C++. The smallest unit of
    >>> operation is a byte.

    >>
    >>
    >> I think & and | and ^ operators work bitwise in C++. That's why they
    >> are called bitwise.
    >>

    >
    > But they work on something no smaller than a char.
    >
    > Actually, with bitfields you can get to smaller items than a char,
    > but in general bytes are the smallest entity.


    No bird is as small as a fly-bird. Actually, some fly-birds are as
    small, but in general birds are bigger than fly-birds.
     
    Someone, Oct 1, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Klett

    <div> tags, some basic questions

    Steve Klett, Nov 13, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    375
    Kevin Spencer
    Nov 13, 2003
  2. Wiktor Zychla

    3 basic questions on asp.net

    Wiktor Zychla, Nov 25, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    427
    Cowboy \(Gregory A. Beamer\)
    Nov 25, 2003
  3. Randall Parker
    Replies:
    3
    Views:
    368
    Trevor Benedict R
    Oct 15, 2005
  4. Engineer
    Replies:
    6
    Views:
    675
    Jeremy Bowers
    May 1, 2005
  5. Replies:
    0
    Views:
    474
Loading...

Share This Page