title: C++ clang linker command failed with exit code 1
body: <p>My professor gave me two class header and .cpp files to build on. When I include these in main, they work fine. Whenever I just use his files, I get linker errors with clang and xcode. </p>
  
  <p>Here's the error:</p>
  
  <pre><code>shannigan@mbp-007100 inheritance (master) $ make main
  c++     main.cpp   -o main
  Undefined symbols for architecture x86_64:
    "SavitchEmployees::SalariedEmployee::SalariedEmployee()", referenced from:
        _main in main-0d7e27.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [main] Error 1
  </code></pre>
  
  <p>Here's my main:</p>
  
  <pre><code>#include "employee.h"
  #include "salariedemployee.h"
  #include &lt;string&gt;
  #include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  
  using namespace SavitchEmployees;
  using namespace std;
  
      int main() {
          cout &lt;&lt; "Do I run?" &lt;&lt; endl;
          SalariedEmployee sam;
          return 0;
      };
  </code></pre>
  
  <p>The header file for Employee:</p>
  
  <pre><code>//This is the header file employee.h.
  //This is the interface for the class Employee.
  //This is primarily intended to be used as a base class to derive
  //classes for different kinds of employees.
  #ifndef EMPLOYEE_H
  #define EMPLOYEE_H
  
  #include &lt;string&gt;
  using std::string;
  
  namespace SavitchEmployees
  {
  
      class Employee
      {
      public:
          Employee( );
          Employee(const string&amp; theName, const string&amp; theSsn);
          string getName( ) const;
          string getSsn( ) const;
          double getNetPay( ) const;
          void setName(const string&amp; newName);
          void setSsn(const string&amp; newSsn);
          void setNetPay(double newNetPay);
          void printCheck( ) const;
      protected:
          string name;
          string ssn;
          double netPay;
      };
  
  }//SavitchEmployees
  
  #endif //EMPLOYEE_H
  </code></pre>
  
  <p>The CPP file for main:</p>
  
  <pre><code>//This is the file: employee.cpp
  //This is the implementation for the class Employee.
  //The interface for the class Employee is in the header file employee.h.
  #include &lt;string&gt;
  #include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include "employee.h"
  using std::string;
  using std::cout;
  
  namespace SavitchEmployees
  {
      Employee::Employee( ) : name("No name yet"), ssn("No number yet"), netPay(0)
      {
          //deliberately empty
      }
  
      Employee::Employee(const string&amp; theName, const string&amp; theNumber)
         : name(theName), ssn(theNumber), netPay(0)
      {
          //deliberately empty
      }
  
      string Employee::getName( ) const
      {
          return name;
      }
  
      string Employee::getSsn( ) const
      {
          return ssn;
      }
  
      double Employee::getNetPay( ) const
      {
          return netPay;
      }
  
     void Employee::setName(const string&amp; newName)
      {
          name = newName;
      }
  
      void Employee::setSsn(const string&amp; newSsn)
      {
          ssn = newSsn;
      }
  
      void Employee::setNetPay (double newNetPay)
      {
          netPay = newNetPay;
      }
  
      void Employee::printCheck( ) const
      {
          cout &lt;&lt; "\nERROR: printCheck FUNCTION CALLED FOR AN \n"
               &lt;&lt; "UNDIFFERENTIATED EMPLOYEE. Aborting the program.\n"
               &lt;&lt; "Check with the author of the program about this bug.\n";
          exit(1);
      }
  
  }//SavitchEmployees
  </code></pre>
  
  <p>SalariedEmployees header:</p>
  
  <pre><code>//This is the header file salariedemployee.h.
  //This is the interface for the class SalariedEmployee.
  #ifndef SALARIEDEMPLOYEE_H
  #define SALARIEDEMPLOYEE_H
  
  #include &lt;string&gt;
  #include "employee.h"
  
  using std::string;
  
  namespace SavitchEmployees
  {
  
      class SalariedEmployee : public Employee
      {
      protected:
          double salary;//weekly
  
      public:
          SalariedEmployee( );
          SalariedEmployee (const string&amp;  theName, const string&amp;  theSsn,
                                    double theWeeklySalary);
          double getSalary( ) const;
          void setSalary(double newSalary);
          void printCheck( );
      };
  
  }//SavitchEmployees
  
  #endif //SALARIEDEMPLOYEE_H
  </code></pre>
  
  <p>SalariedEmployee.cpp:</p>
  
  <pre><code>//This is the file salariedemployee.cpp
  //This is the implementation for the class SalariedEmployee.
  //The interface for the class SalariedEmployee is in
  //the header file salariedemployee.h.
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "salariedemployee.h"
  using std::string;
  using std::cout;
  using std::endl;
  
  namespace SavitchEmployees
  {
      SalariedEmployee::SalariedEmployee( ) : Employee( ), salary(0)
      {
          //deliberately empty
      }
  
      SalariedEmployee::SalariedEmployee(const string&amp;  newName, const string&amp;  newNumber,
                                    double newWeeklyPay)
                       : Employee(newName, newNumber), salary(newWeeklyPay)
      {
          //deliberately empty
      }
  
      double SalariedEmployee::getSalary( ) const
      {
          return salary;
      }
  
      void SalariedEmployee::setSalary(double newSalary)
      {
          salary = newSalary;
      }
  
      void SalariedEmployee::printCheck( )
      {
          setNetPay(salary);
          cout &lt;&lt; "\n__________________________________________________\n";
          cout &lt;&lt; "Pay to the order of " &lt;&lt; getName( ) &lt;&lt; endl;
          cout &lt;&lt; "The sum of " &lt;&lt; getNetPay( ) &lt;&lt; " Dollars\n";
          cout &lt;&lt; "_________________________________________________\n";
          cout &lt;&lt; "Check Stub NOT NEGOTIABLE \n";
          cout &lt;&lt; "Employee Number: " &lt;&lt; getSsn( ) &lt;&lt; endl;
          cout &lt;&lt; "Salaried Employee. Regular Pay: "
               &lt;&lt; salary &lt;&lt; endl;
          cout &lt;&lt; "_________________________________________________\n";
      }
  }//SavitchEmployees
  </code></pre>
  
  <p>How can I get rid of these linker errors so I can focus on my actual code? Is there anything obvious wrong? The only thing I've changed was making the "private" variables protected. </p>