title: Error LNK2019: unresolved external symbol C++ in Qt platform
body: <p>I'm getting these three errors and I have no idea why? I am using the Qt program and and the code below goes in a Qt widget project. The mainwindow.ui is not included because I can't change it anyways. The goal as of now is to get the age into a lineEdit as shown in the mainwindow.cpp file.</p>
  
  <p>I have done things like uninstalled and reinstalled Qt program. Copy and pasted code into a brand new project. Added the header files to cpp files etc etc</p>
  
  <p><strong>Errors:</strong></p>
  
  <pre><code>mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall person::~person(void)" (??1person@@QAE@XZ) referenced in function "public: virtual __thiscall MainWindow::~MainWindow(void)" (??1MainWindow@@UAE@XZ)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall person::person(void)" (??0person@@QAE@XZ) referenced in function "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall person::setAge(int)" (?setAge@person@@QAEXH@Z) referenced in function "private: void __thiscall MainWindow::on_lineEdit_returnPressed(void)" (?on_lineEdit_returnPressed@MainWindow@@AAEXXZ)
  </code></pre>
  
  <p><strong>Here is the code:</strong></p>
  
  <p>mainwindow.h</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QMainWindow&gt;
  #include &lt;string&gt;
  #include "person.h"
  
  namespace Ui {
  class MainWindow;
  }
  
  class MainWindow : public QMainWindow
  {
      Q_OBJECT
  
   public:
      explicit MainWindow(QWidget *parent = 0);
      ~MainWindow();
  
  private slots:
      void on_lineEdit_returnPressed();
  
  private:
      Ui::MainWindow *ui;
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p>person.h</p>
  
  <pre><code>#ifndef PERSON_H
  #define PERSON_H
  
  
  class person
  {
  public:
  
      int age;
  
      person();
      person(int);
  
      ~person();
  
      int getAge();
  
      void setAge(int age);
  };
  
  #endif // PERSON_H
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  #include "person.h"
  #include &lt;QApplication&gt;
  #include &lt;string&gt;
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      MainWindow w;
      w.show();
  
      return a.exec();
  }
  </code></pre>
  
  <p>mainwindow.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include "person.h"
  #include &lt;string&gt;
  
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
  }
  
  MainWindow::~MainWindow()
  {
      delete ui;
  }
  
  void MainWindow::on_lineEdit_returnPressed()
  {
      QString str = ui-&gt;lineEdit-&gt;text();
      std::string age = str.toStdString();
      x.setAge(stoi(age));
      ui-&gt;lineEdit_2-&gt;setText(str);
  }
  </code></pre>
  
  <p>person.cpp</p>
  
  <pre><code>#include "person.h"
  using namespace std;
  
  person::person(int age)
  {
      age = 0;
  }
  
  person::~person()
  {
  
  }
  
  int getAge()
  {
      return age;
  }
  
  void setAge(int age)
  { 
      age = newAge;
  }
  </code></pre>
  
  <p>I have searched and searched and all I know is for some reason the program can't find the setAge() method or cant find the person class. I've even asked other people who know c++ and have no idea why this is happening. Please help!</p>
  
  <p>Deleting:</p>
  
  <pre><code>person x; //in the mainwindow.h file solves this problem but...
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>C:\Users\Adam\Documents\Body_fat\mainwindow.cpp:22: error: C3861: 'setAge': identifier not found
  
  
  
  void MainWindow::on_lineEdit_returnPressed()
  {
      QString str = ui-&gt;lineEdit-&gt;text();
      std::string age = str.toStdString();
      setAge(stoi(age));
      ui-&gt;lineEdit_2-&gt;setText(str);
  }
  </code></pre>