title: Getting the linker error for following c++ code
body: <p>I recently started learning object oriented programming..for the following code, I am getting the linker error !!    </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  class person{
      public:
          string name;
          person();
          person(string n){
              name = n ;
          }
  
          void setName(string k){
              name = k;
          }
          string getName(){
              return name;
          }
  };
  class student : public  person {
      public:
          string major;
          void setMajor(string m){
              major = m;
          }
          string getMajor(){
              return major;
          }
  };
  class faculty : public person{
      public:
          string department;
          faculty(string dept){
              department = dept;
          }
          void setDepartment(string depart){
              department = depart;
          }
          string getDepartment(){
              return department;
          }
  };
  
  int main() {
  
      student s;
  
      s.setName("james");
      s.setMajor("computer science");
  
      string p = s.getName();
      string p2 = s.getMajor();
  
      cout &lt;&lt; "student name and mjor is :" &lt;&lt; p &lt;&lt; p2 &lt;&lt; endl;
      faculty f("nanotech");
      f.setName("chris");
      f.setDepartment("electrical");
      string f1 = f.getName();
      string f2 = f.getDepartment();
      cout &lt;&lt; "facult name and department :" &lt;&lt; f1 &lt;&lt; f2 &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>The following error i am getting , when i try to compile the code.</p>
  
  <pre><code>/tmp/ccYHu2de.o: In function `faculty::faculty(std::string)':
  person.cpp:(.text._ZN7facultyC2ESs[_ZN7facultyC5ESs]+0x19): undefined reference to `person::person()'
  /tmp/ccYHu2de.o: In function `student::student()':
  person.cpp:(.text._ZN7studentC2Ev[_ZN7studentC5Ev]+0x15): undefined reference to `person::person()'
  collect2: error: ld returned 1 exit status
  </code></pre>