Topic: Question on virtual functions


Author: arthur@solomon.technet.sg (Arthur Sombrito)
Date: Wed, 25 Nov 1992 10:16:59 GMT
Raw View
Hi,

I'd like to ask the ARM's specifications regarding overriding and
hiding virtual functions.  ARM seems to be vague regarding this.
For example:

  struct A { virtual void f(); };
  struct B : public A {
    void f(int); // hides A::f()
  };
  struct C : public B {
    void f();  // virtual?
  };
  struct D : public C {
    void f();
  };

  g()
  {
    D d;
    A *aP = &d;
    C *cP = &d;

    aP->f(); // A::f or D::f ?
    cP->f();    // C::f or D::f ?
  }

Thanks for any replies.






Author: arthur@solomon.technet.sg (Arthur Sombrito)
Date: 27 Nov 92 09:01:34 GMT
Raw View
Hi,

I'd like to add another question. Consider this:

   struct A { virtual void f() {} };
   struct B { void f() {} };
   struct C : public A, public B
   {
     void f() {}   // is this virtual?
   };
   struct D : public C
   {
     void f() {}
   };
   g()
   {
     D d;
     C *cP = &d;

     cP->f(); // C::f or D::f ?
   }


Thanks again.