Announcement

Collapse
No announcement yet.

c++ class inheritance question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • c++ class inheritance question

    Hello,

    Again with a C++ implementation question.

    Suppose I have the following situation:
    Code:
    class A {
      protected:
        void f();
    }
    
    class B: protected A {
      public:
         voidf();
    }
    When f is called in class B, I don't want to override it, nor add functionality. I just want the f() from A to be used. IIRC that there was a way of specifying this, but I can't remember...

    I could override it, like so:
    Code:
    void B::f() {
       A::f()
    }
    But I thought the same could be achieved wihout overriding...

    Thanks!


    Jörg
    pixar
    Dream as if you'll live forever. Live as if you'll die tomorrow. (James Dean)

  • #2
    Found it...

    Code:
    class B: protected A {
      public:
         using A::f;
    }


    Jörg
    pixar
    Dream as if you'll live forever. Live as if you'll die tomorrow. (James Dean)

    Comment

    Working...
    X