title: Undefined symbols for architecture x86_64 - Compiling inherited class
body: <p>I currently have an abstract User class and a Student class which inherits from user. I'm attempting to initialize an instance of the Student class from main. I'm receiving this error </p>
  
  <blockquote>
    <p>Undefined symbols for architecture i386:
    "Student::Student()", referenced from:
          _main in ccJo7npg.o
      "Student::~Student()", referenced from:
          _main in ccJo7npg.o
    ld: symbol(s) not found for architecture i386
    collect2: ld returned 1 exit status</p>
  </blockquote>
  
  <p>User Class:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #import &lt;stdio.h&gt;
  #import &lt;string.h&gt;
  using namespace std;
  
  class User
      {
  public:
      void setName(const string n)
  {
      name = n;
  }
  string getName()
  {
      return name;
  }
  void setUsername(const string u)
  {
      username = u;
  }
  string getUsername()
  {
      return username;
  }
  void setPassword(const string p)
  {
      password = p;
  }
  string getPassword()
  {
      return password;
  }
  void setID(const int ID)
  {
      this-&gt;ID=ID;
  }
  int getID()
  {
      return ID;
  }
  void setClassID(const int cid)
  {
      classID=cid;
  }
  int getClassID()
  {
      return classID;
  }
  void logOut()
  {
      cout&lt;&lt;"you have logged out"&lt;&lt;endl;
  }
  void print()
  {
      cout&lt;&lt; "Student : "&lt;&lt; ID &lt;&lt; name &lt;&lt; " "&lt;&lt; username &lt;&lt; " " &lt;&lt; password &lt;&lt; endl;
  }
  virtual void menu()=0;
  protected:
     int classID, ID;
     string name, username, password;
  };
  </code></pre>
  
  <p>Student Class:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "User.h"
  using namespace std;
  
  class Student: public User
  {
  public:
  Student()
  {
      classID=0;
      ID=0;
      username="";
      name="";
      password="";
  }
  ~Student()
  {
      cout&lt;&lt;"destructor"&lt;&lt;endl;
  }
  void studyDeck(const int i)
  {
  
  }
  void viewScores(const int)
  {
  
  }
  void viewScores()
  {
  
  }
  virtual void menu()
  {
      cout &lt;&lt; "Student menu" &lt;&lt; endl;
  }
  };
  </code></pre>
  
  <p>Main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "User.h"
  #include "Student.h"
  using namespace std;
  
  int main()
  {
      Student s;
      return 0;
  }
  </code></pre>
  
  <p>I'm compiling with g++ with " g++ User.cpp Student.cpp main.cpp "</p>
  
  <p>Thanks!</p>