Q: Example from the Holy Writ

Discussion in 'C++' started by Steven T. Hatton, Apr 2, 2004.

  1. This is from the C++ Standard: ISO/IEC 14882:2003(E)
    Any deviation from the text in the Standard document is an unintentional
    transcription error on my part. I'm fairly confident about the reasoning
    behind every part except the line with the comment // does not declare f.
    I'm not sure if it is merely pointing out that no f is declared in the
    definition of VB1a, or suggesting something more subtle. I believe the
    former is the case, and the intent of the example is to show VB2::f()
    overrides the virtual A::f(). Da then inherits the overridden f from VB2.

    This is the DAG of what I think is happening.

    A has virtual f()
    / \
    / \
    / \
    VB1a no f() VB2 overrides f()
    \ /
    \ /
    \ /
    Da inherits f() from VB2

    I am I understanding this correctly?

    /*
    The following example shows a function that does not have a unique
    final overrider:
    */
    struct A {
    virtual void f();
    };

    struct VB1 : virtual A { // note virtual derivation
    void f();
    };

    struct VB2 : virtual A {
    void f();
    };

    /*
    struct Error : VB1, VB2 { // ill-formed
    };
    */

    struct Okay : VB1, VB2 {
    void f();
    };

    /*
    Both VB1::f and VB2::f override A::f but there is no overrider of
    both of them in class Error. This example is therefore
    ill-formed. Class Okay is well formed, however, because Okay::f is a
    final overrider.

    The following example uses the well-formed classes from above.
    */

    struct VB1a : virtual A { // does not declare f
    };

    struct Da : VB1a, VB2 {
    };

    void foe() {
    VB1a* vb1ap = new Da;
    vb1ap->f(); //calls VB2::f
    }

    --
    p->m == (*p).m == p[0].m
    http://www.kdevelop.org
    http://www.suse.com
    http://www.mozilla.org
     
    Steven T. Hatton, Apr 2, 2004
    #1
    1. Advertising

  2. Steven T. Hatton

    pctv06 Guest

    Re: Example from the Holy Writ

    ...fgn,;lgm;
    "Steven T. Hatton" <> wrote in message
    news:...
    > This is from the C++ Standard: ISO/IEC 14882:2003(E)
    > Any deviation from the text in the Standard document is an unintentional
    > transcription error on my part. I'm fairly confident about the reasoning
    > behind every part except the line with the comment // does not declare f.
    > I'm not sure if it is merely pointing out that no f is declared in the
    > definition of VB1a, or suggesting something more subtle. I believe the
    > former is the case, and the intent of the example is to show VB2::f()
    > overrides the virtual A::f(). Da then inherits the overridden f from VB2.
    >
    > This is the DAG of what I think is happening.
    >
    > A has virtual f()
    > / \
    > / \
    > / \
    > VB1a no f() VB2 overrides f()
    > \ /
    > \ /
    > \ /
    > Da inherits f() from VB2
    >
    > I am I understanding this correctly?
    >
    > /*
    > The following example shows a function that does not have a unique
    > final overrider:
    > */
    > struct A {
    > virtual void f();
    > };
    >
    > struct VB1 : virtual A { // note virtual derivation
    > void f();
    > };
    >
    > struct VB2 : virtual A {
    > void f();
    > };
    >
    > /*
    > struct Error : VB1, VB2 { // ill-formed
    > };
    > */
    >
    > struct Okay : VB1, VB2 {
    > void f();
    > };
    >
    > /*
    > Both VB1::f and VB2::f override A::f but there is no overrider of
    > both of them in class Error. This example is therefore
    > ill-formed. Class Okay is well formed, however, because Okay::f is a
    > final overrider.
    >
    > The following example uses the well-formed classes from above.
    > */
    >
    > struct VB1a : virtual A { // does not declare f
    > };
    >
    > struct Da : VB1a, VB2 {
    > };
    >
    > void foe() {
    > VB1a* vb1ap = new Da;
    > vb1ap->f(); //calls VB2::f
    > }
    >
    > --
    > p->m == (*p).m == p[0].m
    > http://www.kdevelop.org
    > http://www.suse.com
    > http://www.mozilla.org
     
    pctv06, Apr 2, 2004
    #2
    1. Advertising

  3. Steven T. Hatton

    rock Guest

    Re: Example from the Holy Writ

    test
    "pctv06" <> дÈëÏûÏ¢ÐÂÎÅ
    :c4j3tl$...
    > ..fgn,;lgm;
    > "Steven T. Hatton" <> wrote in message
    > news:...
    > > This is from the C++ Standard: ISO/IEC 14882:2003(E)
    > > Any deviation from the text in the Standard document is an unintentional
    > > transcription error on my part. I'm fairly confident about the reasoning
    > > behind every part except the line with the comment // does not declare

    f.
    > > I'm not sure if it is merely pointing out that no f is declared in the
    > > definition of VB1a, or suggesting something more subtle. I believe the
    > > former is the case, and the intent of the example is to show VB2::f()
    > > overrides the virtual A::f(). Da then inherits the overridden f from

    VB2.
    > >
    > > This is the DAG of what I think is happening.
    > >
    > > A has virtual f()
    > > / \
    > > / \
    > > / \
    > > VB1a no f() VB2 overrides f()
    > > \ /
    > > \ /
    > > \ /
    > > Da inherits f() from VB2
    > >
    > > I am I understanding this correctly?
    > >
    > > /*
    > > The following example shows a function that does not have a unique
    > > final overrider:
    > > */
    > > struct A {
    > > virtual void f();
    > > };
    > >
    > > struct VB1 : virtual A { // note virtual derivation
    > > void f();
    > > };
    > >
    > > struct VB2 : virtual A {
    > > void f();
    > > };
    > >
    > > /*
    > > struct Error : VB1, VB2 { // ill-formed
    > > };
    > > */
    > >
    > > struct Okay : VB1, VB2 {
    > > void f();
    > > };
    > >
    > > /*
    > > Both VB1::f and VB2::f override A::f but there is no overrider of
    > > both of them in class Error. This example is therefore
    > > ill-formed. Class Okay is well formed, however, because Okay::f is a
    > > final overrider.
    > >
    > > The following example uses the well-formed classes from above.
    > > */
    > >
    > > struct VB1a : virtual A { // does not declare f
    > > };
    > >
    > > struct Da : VB1a, VB2 {
    > > };
    > >
    > > void foe() {
    > > VB1a* vb1ap = new Da;
    > > vb1ap->f(); //calls VB2::f
    > > }
    > >
    > > --
    > > p->m == (*p).m == p[0].m
    > > http://www.kdevelop.org
    > > http://www.suse.com
    > > http://www.mozilla.org

    >
    >
     
    rock, Apr 2, 2004
    #3
  4. Re: Example from the Holy Writ

    rock wrote:
    > test


    Please don't spam this group with this useless crap. There are groups
    for testing, and this isn't one of them. There's also no need to quote
    80 irrelevant lines of text. And in the future, if you have something
    useful to say, please post correctly (e.g., don't top-post).

    http://www.parashift.com/c -faq-lite/how-to-post.html

    -Kevin
    --
    My email address is valid, but changes periodically.
    To contact me please use the address from a recent posting.
     
    Kevin Goodsell, Apr 2, 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. Jerry

    Holy JUMPING frameset Batman!

    Jerry, Jan 27, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    318
    Jerry
    Jan 27, 2004
  2. Sky

    And for the holy grail...

    Sky, Jan 28, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    600
  3. gacrux

    The Holy Shroud

    gacrux, Feb 12, 2005, in forum: HTML
    Replies:
    0
    Views:
    435
    gacrux
    Feb 12, 2005
  4. Give me liberty!

    Free MP3 (Holy Quran)

    Give me liberty!, Aug 30, 2004, in forum: C++
    Replies:
    0
    Views:
    3,237
    Give me liberty!
    Aug 30, 2004
  5. Greg Ewing
    Replies:
    1
    Views:
    327
    Horst F. JENS
    Aug 1, 2006
Loading...

Share This Page