Undefined reference to a defined function
<p>So presumably I am doing something incredibly stupid and just catch it, but I keep getting an undefined reference to a function that I have most definitely defined. In one of my .cpp files, I use the following command:</p>

<pre><code>#include "MVec.h"
...
MVec ans;
...
for(int i = 0; i &lt; 3; i++)
    ans[i] = ...
</code></pre>

<p>In MVec.h, I have:</p>

<pre><code>class MVec {
...
inline double &amp; operator[](const int i);
inline const double &amp; operator[](const int i) const;
...
};
</code></pre>

<p>Finally, in mvec.cpp, I have:</p>

<pre><code>inline double &amp; MVec::operator[](const int i) {
        #ifdef CHECK_BOUNDS
        if(i &lt; 0 || i &gt;= 3)
                throw("Subscript out of bounds");
        #endif

        return vec[i];
}

inline const double &amp; MVec::operator[](const int i) const {
        #ifdef CHECK_BOUNDS
        if(i &lt; 0 || i &gt;= 3)
                throw("Subscript out of bounds");
        #endif

        return vec[i];
}
</code></pre>

<p>Somehow, however, when I compile the two .cpp files and try to link them</p>

<pre><code>g++ atommanager.cpp -o atommanager.o
g++ mvec.cpp -o mvec.o
g++ atommanager.o mvec.o -o gpumd
</code></pre>

<p>I always get an error:</p>

<pre><code>atommanager.cpp:(.text+0x76): undefined reference to `MVec::operator[](int)'
</code></pre>

<p>Here, atommanager.cpp is the name of the first .cpp file I mentioned.</p>
