title: Memory allocation for member functions in C++
body: <pre><code>#include&lt;iostream&gt;
  using namespace std;
  class A
  {
  
  };
  class B
  {
          public:
                  void disp()
                  {
                          cout&lt;&lt;" This is not virtual function.";
                  }
  };
  class C
  {
          public:
                  virtual void disp()
                  {
                          cout&lt;&lt;"This is virtual function.";
                  }
  };
  int main()
  {
          cout&lt;&lt;"class A"&lt;&lt;sizeof(A)&lt;&lt;endl;
          cout&lt;&lt;"class B"&lt;&lt;sizeof(B)&lt;&lt;endl;
          cout&lt;&lt;"class C"&lt;&lt;sizeof(C)&lt;&lt;endl;
          return 0;
  }
  </code></pre>
  
  <p>sizeof class A and class B are both 1 byte only.What about the memory allocation for member function disp in B. </p>