C++ Undefined Reference
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3656050/c-undefined-reference-to-foofoostdstring">c++ &ldquo; undefined reference to &#39;Foo::Foo(std::string)&#39; &rdquo;</a>  </p>
</blockquote>



<p>I got three <code>.cpp</code> files and <code>two header files.</code></p>

<p>But when i compile them, meaning the <code>Point.cpp</code>, <code>Data.cpp</code> and <code>main.cpp</code>, it will say </p>

<pre><code>main.cpp: undefined reference to "PointD::PointD()' collect2: ld returned 1 exit status 
</code></pre>

<p>Below is my <code>Data.h</code>:</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 <code>data.cpp</code>:</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 <code>PointD.h</code>:</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 <code>PointD.cpp</code>:</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 <code>main.cpp</code>:</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 <code>Point.cpp</code>, <code>Data.cpp</code> and <code>main.cpp</code>, it will say </p>

<p>main.cpp: undefined reference to "PointD::PointD()' collect2: ld returned 1 exit status </p>
