title: How to deallocate the dynamically allocated classes?
body: <p><strong>I have this simple program below:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;            
  using namespace std;
  
  class pithikos {
  
  public:
      //constructor
      pithikos(int x, int y){
          xPosition = x;
          yPosition = y;
      }
  
      //multiplicator of x and y positions
      int xmuly(){
          return xPosition*yPosition;
      }   
  
  private:
      int xPosition;
      int yPosition;
  };
  
  int main(void){
  
  
  //alloccate memory for several number of pithikous
  pithikos **pithik = new pithikos*[10];
  for (int i = 0; i&lt;10; i++){
       pithik[i] = new pithikos(i,7);
  }
  
  cout &lt;&lt; pithik[3]-&gt;xmuly() &lt;&lt; endl; /*simple print statement for one of the pithiks*/
  
  //create pithikos1 
  pithikos pithikos1(5,7);
  cout &lt;&lt; pithikos1.xmuly() &lt;&lt; endl;
  
  //delete alloccated memory
  for (int i=0; i&lt;10; i++) delete pithik[i];
  delete [] pithik;
  cout &lt;&lt; pithik[4]-&gt;xmuly() &lt;&lt; endl;
  }
  </code></pre>
  
  <p>The class just takes two numbers and multiplies them and return the value.
  But I want the oblects to born and die.</p>
  
  <p>So I allocated in this example 10 objects (pithikos) and then I am testing weather it works.</p>
  
  <p>when I ran the program I get this:</p>
  
  <blockquote>
    <p>21</p>
    
    <p>35</p>
    
    <p>28</p>
  </blockquote>
  
  <p>my problem is: why do I get the value 28 after I used the command?</p>
  
  <p><code>delete [] pithik;</code></p>
  
  <p>how can I delete the objects if not like this?</p>