title: Why does my class not link?
body: <p>This week I started to upgrade my knowledge from C to C++, I would like to overload some operators</p>
  
  <p>I have a class called Matrix</p>
  
  <pre><code>#include "lcomatrix.h"
  
  inline Matrix::Matrix(unsigned rows, unsigned cols) :
          rows_(rows), cols_(cols)
  {
          data_ = new double[rows * cols];
  }
  
  inline Matrix::~Matrix() {
      delete[] data_;
  }
  
  inline double&amp; Matrix::operator()(unsigned row, unsigned col) {
      return data_[cols_ * row + col];
  }
  
  inline double Matrix::operator()(unsigned row, unsigned col) const {
      return data_[cols_ * row + col];
  }
  </code></pre>
  
  <p>The content of <code>lcomatrix.h</code> is</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class Matrix {
  public:
      Matrix(unsigned rows, unsigned cols);
      double&amp; operator()(unsigned row, unsigned col);
      double operator()(unsigned row, unsigned col) const;
  
      ~Matrix(); // Destructor        
      Matrix&amp; operator=(Matrix const&amp; m); // Assignment operator      
  
  private:
      unsigned rows_, cols_;
      double* data_;
  };
  </code></pre>
  
  <p>Main.cpp</p>
  
  <pre><code>#include "lcomatrix.h"
  #include &lt;iostream&gt;
  
  
  /*-
   * Application entry point.
   */
  int main(void) {
  
      Matrix mx(12,12);
  
      //std::cout &lt;&lt; mx &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>Make file:</p>
  
  <pre><code>CPPFLAGS=-I /path/lcomatrix/
  EFLAGS=
  
  all : main.o lcomatrix.o
      g++ $(EFLAGS) -o main.out  main.o lcomatrix.o 
  
  main.o: lcomatrix.o
      g++ $(EFLAGS) $(CPPFLAGS) -c main.cpp
  
  lcomatrix.o: 
      g++ $(EFLAGS) -c /home/robu/UbuntuOne/ChibiOS-RPi/lcomatrix/lcomatrix.cpp
  
  clean:
      rm *.o main.out 
  </code></pre>
  
  <p>When I try to build I receive the following link error:</p>
  
  <pre><code>make all 
  g++  -c /home/robu/UbuntuOne/ChibiOS-RPi/lcomatrix/lcomatrix.cpp
  g++  -I /home/robu/UbuntuOne/ChibiOS-RPi/lcomatrix/ -c main.cpp
  g++  -o main.out  main.o lcomatrix.o 
  main.o: In function `main':
  main.cpp:(.text+0x1b): undefined reference to `Matrix::Matrix(unsigned int, unsigned int)'
  main.cpp:(.text+0x2c): undefined reference to `Matrix::~Matrix()'
  collect2: error: ld returned 1 exit status
  make: *** [all] Error 1
  </code></pre>
  
  <p>I guess this a really stupid error, but as a beginner I couldn't figure out the solution. </p>