Implicitly declared/defined member functions and inheritance

Discussion in 'C++' started by lovecreatesbeauty, May 9, 2005.

  1. The following shortened table comes from a big company's C++ technical
    document accompanied with its C++ compiler. This company's C++ compiler
    was/is very popular in Windows platform programming. But I'm not sure
    whether this table is accurate.

    The language standard says "Operator functions are inherited", I guess
    that it means all operator functions are inherited. But that table says
    operator = is not. Is operator = an exception?

    Could you please give me a another correct list to explain:

    1. which member functions can be declared and/or defined implicitly?

    2. which member functions can't be inherited in derived class?


    Thank you.



    -- Quotation 1 ---------------------------------------

    --------------- inheritable ? -- provided implicitly ?

    ------------------------------------------------------

    constructor -------- no ---------------- yes ---------

    copy constructor --- no ---------------- yes ---------

    destructor --------- no ---------------- yes ---------

    operator = --------- no ---------------- yes ---------

    -- Quotation 1 ends ----------------------------------



    -- Quotation 2: ISO/IEC 14882 ---------------

    13.5 Overloaded operators

    6 ...The meaning of the operator = , (unary) &, and , (comma),
    predefined for each type, can be changed for specific class and
    enumeration types by defining operator functions that implement these
    operators. Operator functions are inherited in the same manner as other
    base class functions.
    ....
    -- Quotation 2 ends -------------------------
    lovecreatesbeauty, May 9, 2005
    #1
    1. Advertising

  2. lovecreatesbeauty wrote:

    > The following shortened table comes from a big company's C++ technical
    > document accompanied with its C++ compiler. This company's C++ compiler
    > was/is very popular in Windows platform programming. But I'm not sure
    > whether this table is accurate.
    >
    > The language standard says "Operator functions are inherited", I guess
    > that it means all operator functions are inherited. But that table says
    > operator = is not. Is operator = an exception?



    Are you talking about C++/CLI and .NET 2? In .NET the base Object class has its operator=
    disabled (private). If you define it as public in one of your classes, then all of your
    derived classes of it, will also have operator=. C#/CLI on the other hand, "magically"
    comes with an implicit operator= for user-defined classes, C++ however preserves this
    semantics.


    --
    Ioannis Vranos

    http://www23.brinkster.com/noicys
    Ioannis Vranos, May 9, 2005
    #2
    1. Advertising

  3. lovecreatesbeauty

    Jack Klein Guest

    On Mon, 09 May 2005 10:35:11 +0300, Ioannis Vranos
    <> wrote in comp.lang.c++:

    > lovecreatesbeauty wrote:
    >
    > > The following shortened table comes from a big company's C++ technical
    > > document accompanied with its C++ compiler. This company's C++ compiler
    > > was/is very popular in Windows platform programming. But I'm not sure
    > > whether this table is accurate.
    > >
    > > The language standard says "Operator functions are inherited", I guess
    > > that it means all operator functions are inherited. But that table says
    > > operator = is not. Is operator = an exception?

    >
    >
    > Are you talking about C++/CLI and .NET 2?


    If he is, he is off-topic here, just as your reply is.

    Kindly keep your ramblings about yet another non-standard extension
    out of this group.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
    Jack Klein, May 10, 2005
    #3
  4. Jack Klein wrote:

    > If he is, he is off-topic here, just as your reply is.
    >
    > Kindly keep your ramblings about yet another non-standard extension
    > out of this group.



    Actually it is a standardised *extension* to C++2003. :) Not part of ISO C++ though,
    however some features of C++/CLI *will* become part of the core C++0x in the future, and
    also it describes how C++ can interact with a VM.

    Also the parts of it does not include any Forms, TextBoxes, etc that you may be afraid of,
    any API usage is considered system-specific there too, the additional facilities provided
    are minimal (actually apart from the Console class and String type I can't remember
    something more).


    Of course, the majority of the regulars will decide what will be topical here in the
    future, however there can't be another newsgroup for C++/CLI, because it is ISO C++
    extensions and can not "live" without ISO C++.



    --
    Ioannis Vranos

    http://www23.brinkster.com/noicys
    Ioannis Vranos, May 10, 2005
    #4
  5. Vranos, you can post another thread to talk about what you'er talking
    about.

    I want to know, in C++ (ISO/IEC 14882:1998):

    1. For a class, which member functions can be declared/defined
    implicitly.

    2. Which base class members can't be inherited in derived class.
    lovecreatesbeauty, May 10, 2005
    #5
  6. lovecreatesbeauty wrote:

    > Vranos, you can post another thread to talk about what you'er talking
    > about.
    >
    > I want to know, in C++ (ISO/IEC 14882:1998):
    >
    > 1. For a class, which member functions can be declared/defined
    > implicitly.



    When you create a class SomeClass, an assignment operator and a copy constructor are
    created implicitly which provide shallow copying (all data members are copied value-wise),
    also a "default" constructor doing nothing ( SomeClass() ) and a "default" destructor
    doing nothing.


    > 2. Which base class members can't be inherited in derived class.



    Everything is inherited (and can be disabled). Perhaps you may clarify what you mean with
    "inherited".



    --
    Ioannis Vranos

    http://www23.brinkster.com/noicys
    Ioannis Vranos, May 10, 2005
    #6
  7. ------- quotation: ISO/IEC 14882 -------

    10.3 Virtual functions

    4. Even though destructors are not inherited, a destructor in a
    derived overrides a base class destructor declared virtual;
    ....


    12.3.2 Conversion functions

    5. Conversion functions are inherited.


    13.5 Overloaded operators

    6. ...The meaning of the operator = , (unary) &, and , (comma),
    predefined for each type, can be changed for specific class and
    enumeration types by defining operator functions that implement these
    operators. Operator functions are inherited in the same manner as other
    base class functions.

    ------- quotation ends -------

    I've be taught that constructors, destructor and copy assignment are
    not inherited from base classes in derived classes. As for these
    members, derived classes will always have its own members instead of
    inherit them from father classes.

    But I don't find a complete list of these members from the language
    standard.

    Thank you.
    lovecreatesbeauty, May 10, 2005
    #7
  8. I found that Bruce Eckel talked about this topic in his `thinking in
    C++, 2nd` section 14.

    regards
    lovecreatesbeauty, May 12, 2005
    #8
    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. Guenther Sohler
    Replies:
    6
    Views:
    1,036
    anthius
    Oct 7, 2006
  2. Replies:
    3
    Views:
    440
  3. Ninereeds
    Replies:
    2
    Views:
    287
    Ninereeds
    Apr 3, 2007
  4. Paavo Helde
    Replies:
    3
    Views:
    261
    Pete Becker
    May 22, 2007
  5. ramu
    Replies:
    2
    Views:
    371
    Marcel Müller
    Sep 1, 2009
Loading...

Share This Page