title: calling parent function on a specific function call of every child C++
body: <p>So assume there is class A with function foo.<br>
  Class A is the parent of a few classes which all have the function foo.<br>
  All of the child classes  need the functionality of
      <code>A::foo</code> and adds upon it.<br>
  For example:</p>
  
  <pre><code>    class A
      {
      public:
        void foo()
        {
           print('A');
        }
      };
  
      class B:public A
      {
      public: 
         void foo()
         {
            print("B");
         }
      };
      class C:public A
      {
      public:
        void foo()
          {
             print("C");
          }
      };
      void main()
      {
         B b;
         C c;
         c.foo()// now only goes to C::foo(), meaning print C. I want it to to also go into A::foo() meaning print AC
         b.foo()//now only goes to B::foo(),meaning print B. want it to print AB
      }
  </code></pre>
  
  <p>And if I want to add <code>class D : A</code> with foo function it will also do <code>A::foo()</code> and then <code>D::foo()</code>    </p>
  
  <p>Sorry if I am missing something obvious.  </p>
  
  <p>EDIT : since it wasn't clear the question was if there is an automatic way to do so.  </p>
  
  <p>EDIT : found a workaround:</p>
  
  <pre><code>    class A
      {
      virtual void foo2(){}
      public:
        void foo()
        {
           print('A');
           foo2();
        }
  
      };
  
      class B:public A
      {
         void foo2()
         {
            print("B");
         }
      public: 
      };
      class C:public A
      {
                void foo2()
          {
             print("C");
          }
          public:
      };
      void main()
      {
         B b;
         C c;
         c.foo()// now prints AC
         b.foo()//now prints AB
      }
  </code></pre>
  
  <p>seems redundant since now there are 2 functions now.</p>