title: Polymorphism in c++ - Access functions over pointers
body: <p>Got the following simple structure:</p>
  <pre><code>    class Base {
      public:
          virtual void foo() { std::cout &lt;&lt; &quot;Base&quot; &lt;&lt; std::endl; }
      };
      
      class Derived1 : public Base {
      public:
          void foo() override { std::cout &lt;&lt; &quot;Derived1&quot; &lt;&lt; std::endl; }
          void boo() {}
      };
      
      class Derived2 : public Base {
      public:
          void foo() override { std::cout &lt;&lt; &quot;Derived2&quot; &lt;&lt; std::endl; }
      };
      
      int main(){
          Base* p1 = new Derived1();
          Base* p2 = new Derived2();
      
          p1-&gt;foo();
          p1-&gt;boo();
      }
  </code></pre>
  <p>Now my question is: how can i access the Derived1::boo() function (with the pointer p1, so I still have the polymorphism) when i don't want it to be accessible for objects of Derived2?</p>