title: Redefinition of class
body: <p>I got three <code>.cpp</code> files and <code>two header files.</code></p>
  
  <p>But when i compile them, meaning the Point.cpp, Data.cpp and main.cpp, it will say </p>
  
  <pre><code>Data.h:6:7 redefinition of Data at 'Data.h'
  Data.h:6:7 previously definition of 'class Data'
  </code></pre>
  
  <p>Below is my Data.h(previously known as 2.h at above)</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  class Data
  {
  private:
  string sType;
  public:
  Data();
  Data(string);
  void setSType(string);
  string getSType();
  };
  </code></pre>
  
  <p>Below is my data.cpp</p>
  
  <pre><code>#include "Data.h"
  
  Data::Data()
  {
  sType = "";
  }
  
  Data::Data(string s)
  {
  sType = s;
  }
  
  void Data::setSType(string ss)
  {
  sType = ss;
  }
  
  string Data::getSType()
  {
  return sType;
  }
  </code></pre>
  
  <p>Below is my PointD.h (previously known as 3.h)</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "Data.h"
  
  using namespace std;
  
  class PointD
  {
  private:
  int x
  Data data1;
  public:
  PointD();
  PointD(int,Data);
  
  void setX(int);
  void setData(Data);
  
  int getX();
  Data getData();
  };
  </code></pre>
  
  <p>Below is my PointD.cpp</p>
  
  <pre><code>#include "PointD.h"
  
  PointD::PointD()
  {
  x = 0;
  }
  
  PointD::PointD(int xOrdinate,Data dd)
  {
  x = xOrdinate;
  data1 = dd;
  }
  
  void PointD::setXordinate(int Xordinate)
  {
  x = Xordinate;
  }
  
  void PointD::setData(Data dd)
  {
  data1 = dd;
  };
  
  int PointD::getXordinate()
  {
  return x;
  }
  
  Data PointD::getData()
  {
  return data1;
  }
  </code></pre>
  
  <p>This is my main.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  #include "Data.h"
  #include "PointD.h"
  using namespace std;
  
  int main()
  {
  const int MAX_NUM = 20;
  
  Data ldata[MAX_NUM];
  PointD pointd[MAX_NUM];
  
  //more codes..
  }
  </code></pre>
  
  <p>But when i compile them, meaning the Point.cpp, Data.cpp and main.cpp, it will say </p>
  
  <pre><code>Data.h:6:7 redefinition of Data at 'Data.h'
  Data.h:6:7 previously definition of 'class Data'
  </code></pre>
  
  <p><em>Can anybody let me know  whats actually went wrong here..</em></p>