I have encountered "c2512" error even if I declared the constructor. My code is like this: in my "first.h" file, I declared it like:
class myClass
{
public:
tmpM ( cv::Mat& _model );
}
then in my "first.cpp" I did:
#include "first.h"
myClass::tmpM ( cv::Mat& _model )
{
...
}
Then I included this "first.h" in my "second.h", then included this "second.h" in my "third.h", and called this class in my "third.cpp" like this:
cv::Mat myMat ( height, width, CV_8UC3 );
tmpM aM ( myMat );
But this gives out an c2512 error, saying
no appropriate default constructor available
I indeed searched about this, and found I should build a default constructor by myself, and I tried to do it like this in my "first.h":
class myClass
{
public:
tmpM ( cv::Mat& _model) {};
}
Then got an error saying:
function "myClass::tmpM" already has a body
I tried several other methods to do it but still couldn't solve it. I don't need to build a default constructor here I think, but still bothered with it. Could someone help me?
Edit
Ok, after your suggestions, I changed it into this form:
class myClass
{
public:
myClass(cv::Mat& _model ) : tmpM (_model)
{
}
private:
cv::Mat& tmpM;
};
Then in my "first.cpp", I got an error saying
declaration is incompatible
How could this be solved?