title: Where (in which memory segment) are objects (of a class) stored in C++?
body: <p>Let's take the following class for example</p>
  
  <pre><code>class Shape{
      public:
        Circle (int x): number(x){}
        virtual area () {return x**2;}
  
      private:
        int number;
  }
  </code></pre>
  
  <p>In main we create the objects</p>
  
  <pre><code>int main(){
      Shape *foo = new Shape(8);
      Shape *bar = new Shape(65);
      Shape &amp;obj1 = *foo, &amp;obj2 = *bar;
  }
  </code></pre>
  
  <p>I believe the objects 1 and 2 are stored in the heap. Why is that?
  As a side question. Does the keyword virtual, or/and the way objects are defined (eg. obj1 = *foo), impact the positioning thereof in the memory?</p>