title: Undefined Reference in CLion
body: <p>I made a small test project in C++ and in CLion IDE:</p>
  
  <p>main.cpp</p>
  
  <pre><code>#include "testclass.h"
  
  int main() {
  
      testclass *test = new testclass();
      test-&gt;foo();
  
      return 0;
  }
  </code></pre>
  
  <p>testclass.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "testclass.h"
  
  using namespace std;
  
  void testclass::foo(){
      cout &lt;&lt; "Hello, World!" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>testclass.h </p>
  
  <pre><code>class testclass {
  public:
      void foo();
  
  };
  </code></pre>
  
  <p>CMakeLists.txt</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.9)
  project(untitled1)
  
  set(CMAKE_CXX_STANDARD 11)
  
  add_executable(untitled1 main.cpp)
  </code></pre>
  
  <p>The CMakeList.txt is created by the IDE automatically and I haven't changed it.
  When I try to run this simple program I get the following errors:</p>
  
  <pre><code>CMakeFiles/untitled1.dir/main.cpp.o: In function `main':
  /home/irene/CLionProjects/untitled1/main.cpp:7: undefined 
  reference to `testclass::foo()'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Can someone help me understand what am I doing wrong?</p>