Copy constructor hides default constructor

Discussion in 'C++' started by Aire, Jan 24, 2004.

  1. Aire

    Aire Guest

    Will defining a copy constructor also make the default constructor not
    available anymore, until a default constructor is explicitly provided?
    Thanks!
     
    Aire, Jan 24, 2004
    #1
    1. Advertising

  2. Aire

    Jumbo Guest

    "Aire" <> wrote in message
    news:r9pQb.7514$...
    > Will defining a copy constructor also make the default constructor not
    > available anymore, until a default constructor is explicitly provided?
    > Thanks!
    >
    >


    Yes I think it does.
    If you provide a copy constructor then you'll need to provide a default
    constructor.

    Be carefull when using the phrase 'constructor explicitly provided' as this
    could be confused with a 'constructor using the explicit keyword'.
     
    Jumbo, Jan 24, 2004
    #2
    1. Advertising

  3. "Aire" <> wrote in message
    news:r9pQb.7514$...
    > Will defining a copy constructor also make the default constructor not
    > available anymore, until a default constructor is explicitly provided?
    > Thanks!
    >


    Yes, implicit default constructor only generated if no other constructors
    are defined. This is for compatibility with C struct's.

    John
     
    John Harrison, Jan 24, 2004
    #3
  4. Aire

    Mike Wahler Guest

    "Jumbo @uko2.co.uk>" <pcr1000011<nospam> wrote in message
    news:...
    >
    > "Aire" <> wrote in message
    > news:r9pQb.7514$...
    > > Will defining a copy constructor also make the default constructor not
    > > available anymore, until a default constructor is explicitly provided?
    > > Thanks!
    > >
    > >

    >
    > Yes I think it does.
    > If you provide a copy constructor


    Clarification:

    *any* constructor

    >then you'll need to provide a default
    > constructor.


    Only if one is needed.

    -Mike
     
    Mike Wahler, Jan 25, 2004
    #4
    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. Tom
    Replies:
    3
    Views:
    507
  2. Alex
    Replies:
    2
    Views:
    1,254
  3. Replies:
    2
    Views:
    361
    Old Wolf
    Sep 12, 2005
  4. Generic Usenet Account
    Replies:
    10
    Views:
    2,282
  5. cinsk
    Replies:
    35
    Views:
    2,655
    James Kanze
    Oct 11, 2010
Loading...

Share This Page