title: C++ Inheritance and Constructors
body: <p>trying to work out how to use constructors with an inherited class. I know this is very much wrong, I've been writing C++ for about three days now, but here's my code anyway:</p>
  
  <p>clientData.h, two classes, ClientData extends Entity :</p>
  
  <pre><code>#pragma once
  
  class Entity
  {
  public:
   int x, y, width, height, leftX, rightX, topY, bottomY;
  
   Entity(int x, int y, int width, int height);
   ~Entity();
  };
  
  class ClientData : public Entity
  {
  public:
   ClientData();
   ~ClientData();
  };
  </code></pre>
  
  <p>and clientData.cpp, which contains the functions:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "clientData.h"
  using namespace std;
  
  Entity::Entity(int x, int y, int width, int height)
  {
   this-&gt;x = x;
   this-&gt;y = y;
   this-&gt;width = width;
   this-&gt;height = height;
  
   this-&gt;leftX = x - (width/2);
   this-&gt;rightX = x + (width/2);
     this-&gt;topY = y - (height/2);
   this-&gt;bottomY = y + (height/2);
  }
  
  Entity::~Entity()
  {
   cout &lt;&lt; "Destructing.\n";
  }
  
  ClientData::ClientData()
  {
   cout &lt;&lt; "Client constructed.";
  }
  
  ClientData::~ClientData()
  {
      cout &lt;&lt; "Destructing.\n";
  }
  </code></pre>
  
  <p>and finally, I'm creating a new ClientData with:</p>
  
  <pre><code>ClientData * Data = new ClientData(32,32,32,16);
  </code></pre>
  
  <p>Now, I'm not surprised my compiler shouts errors at me, so how do I pass the arguments to the right classes?</p>
  
  <p>The first error (from MVC2008) is
  error C2661: 'ClientData::ClientData' : no overloaded function takes 4 arguments</p>
  
  <p>and the second, which pops up whatever changes I seem to make is
  error C2512: 'Entity' : no appropriate default constructor available 
  Thanks.</p>