out-of-line definition of 'function' does not match any declaration in 'Class'
<p>So I'm working on an iOS project using OpenCV and am currently trying to import part of an existing c++ project into the iOS app, and this error has recently come up. I'm still quite new to both to C++ and objective C, so maybe I'm missing something painfully obvious. </p>

<p>I've noticed that attempting to define and implement any new functions in the Contour namespace results in the same error, and adding the virtual specifier does not seem to change this. The draw function does not experience the problem though. I've also tried quitting and restarting xcode as suggested in similar questions, but the problem persists.</p>

<p>The function writeToFile(string fname) is defined in the header file, as you can see below, yet in the implementation file the error complains that "out-of-line definition of 'writeToFile' does not match any declaration in 'Contour'":</p>

<p>2DContour.h:</p>

<pre><code>#ifndef TWODCONTOUR_H
#define TWODCONTOUR_H


#include &lt;vector&gt;
using std::vector;
#include &lt;opencv2/core.hpp&gt;
using namespace cv;

class Contour
{
protected:
    vector&lt;Vec2f&gt; points;   
    virtual void process(){} // virtual function interface for after-creation/edit processing (eg. refinement/validation)
public:
    inline Vec2f at(int index){return points[index];}
    inline void clear(){points.clear();}
    inline void addPoint(Vec2f p){points.push_back(p);}
    inline void finish(){process();}
    inline void randomize(int num)
    {
        num--;
        points.clear();
        int cycles=6;//rand()%6+1;
        float offset=(float)rand()/(float)RAND_MAX*2.0f*3.141592654f;
        float noisemag=(float)rand()/(float)RAND_MAX;
        for(int i=0;i&lt;num;i++)
        {
            float a=(float)i/(float)num;
            addPoint(
                    Vec2f(sin(a*2.0f*3.141592654f),cos(a*2.0f*3.141592654f))+
                    noisemag*Vec2f(sin(cycles*a*2.0f*3.141592654f+offset),cos(cycles*a*2.0f*3.141592654f+offset)));
        }
        addPoint(points.front());
        process();
    }
    void writeToFile(String fname);
    virtual Mat draw(Mat canvas, bool center=false, Scalar colour=Scalar(255,255,255), int thickness=1);
    inline int numPoints(){return points.size();}
    inline Vec2f getPoint(int i){return points[i];}
};



#endif
</code></pre>

<p>2DContour.cpp:</p>

<pre><code>#include &lt;opencv2/highgui.hpp&gt;
#include &lt;opencv2/imgproc.hpp&gt;
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include "2DContour.h"

using namespace std;
using namespace cv;

//error occurs here
void Contour::writeToFile(string fname)
{
    ofstream out;
    out.open(fname.c_str());
    for(unsigned int i=0;i&lt;points.size();i++)
        out &lt;&lt; points[i][0]&lt;&lt;" "&lt;&lt;points[i][1]&lt;&lt;endl;
    out.close();
    std::cout&lt;&lt;"Wrote: "&lt;&lt;fname&lt;&lt;std::endl;
}

//draw() function does not experience the same error however
Mat Contour::draw(Mat canvas, bool center, Scalar colour, int thickness)
{
    Mat r=canvas.clone();
    cv::Point c(center?r.cols/2:0,center?r.rows/2:0);

     for( unsigned int j = 0; j &lt; points.size(); j++ )
         {
             line(r,c+ cv::Point(points[j]*50),c+ cv::Point(points[(j+1)%points.size()]*50),colour,thickness, 8 );
         }
     return r;
}
</code></pre>

<p>Any help would be appreciated.</p>