title: "Undefined symbols for architecture x86_64" in terminal but no error in xcode
body: <p>This is driving me nuts. I don't understand what the error is telling me and it only appears when I compile using the terminal and call the function. If I include the class.h, make a member called "first", there is no error, but if I call the function "first.coutTest()" there is an error, BUT NO ERROR WHEN I USE XCODE! </p>
  
  <p>Why am I getting an error in terminal?! </p>
  
  <p>this is main.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "class.h"
  using namespace std;
  
  int main(void){
      TestClass first;    
      first.coutTest();   
      cout &lt;&lt; "test" &lt;&lt; endl; 
      return 0;
  }
  </code></pre>
  
  <p>here is my class.h</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  class TestClass{
      int number;
  public:
      void coutTest();
  };
  </code></pre>
  
  <p>here is my class.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "class.h"
  using namespace std; 
  
  void TestClass::coutTest(){
      cout &lt;&lt; "class test" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Again, no error when I run it in xcode, so xcode must be doing something I'm not. Could someone please tell me what's going on? </p>
  
  <p>Specific error I get is when I use <code>make</code> or <code>g++</code> is the same:</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
    "TestClass::coutTest()", referenced from:
        _main in main-f2c376.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation) 
  </code></pre>
  
  <p>I am running Yosemite 10.10.1 on a MacBook Pro (15-inch, Late 2011) Processor 2.2 GHz Intel Core i7 with Graphics Intel HD Graphics 3000 384 MB. </p>
  
  <hr>
  
  <p>Edit update: </p>
  
  <p>So now I've got it working in terminal when I include "class.cpp" instead of "class.h". 
  I was my understanding that this is bad practice, so I'm hesitant to do this.
  Why does xcode have me include files differently. Why doesn't program work the same way in terminal? </p>