title: How functions are resolved by compiler?
body: <p>How it is determined whether the below call is bound at compile time or at runtime?</p>
  
  <pre><code>object.member_fn;//object is either base class or derived class object
  p-&gt;member_fn;//p is either base class or derived class pointer
  </code></pre>
  
  <p>EDITED:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  class Base
  {
         public:
            Base(){ cout&lt;&lt;"Constructor: Base"&lt;&lt;endl;}
            ~Base(){ cout&lt;&lt;"Destructor : Base"&lt;&lt;endl;}
  };
  class Derived: public Base
  {
       //Doing a lot of jobs by extending the functionality
         public:
             Derived(){ cout&lt;&lt;"Constructor: Derived"&lt;&lt;endl;}
             ~Derived(){ cout&lt;&lt;"Destructor : Derived"&lt;&lt;endl;}
   };
  void foo()
  {
      Base &amp; Var = Derived();
      Base*pVar = new Derived;
      delete pVar;
  }
  void main()
  {
      foo();
          std::cin.get();
  }
  
  
  out put:
  Constructor: Base
  Constructor: Derived
  Constructor: Base
  Constructor: Derived
  Destructor : Base // the Derived is not called,
                    // the PVal is of type Base* and the fn is not virtual 
                    //so compile time binding
  Destructor : Derived
  Destructor : Base
  </code></pre>