alittlebirdy
alittlebirdy

Reputation: 93

C++ compiler complaining about no default constructor

Given this struct with a private stateful variable:

struct Calibrate
{
private:
    Stitcher stitcher_obj_;

}

This is the stitcher object (with empty constructor):

Stitcher::Stitcher(const std::vector<cv::Mat> &src_images){}

When calling Calibrate, I am getting this error:

default constructor of 'Calibrate' is implicitly deleted because field 'stitcher_obj_' has no default constructor
Stitcher stitcher_obj_
         ^

Thanks for any suggestions on how to fix this!

Upvotes: 1

Views: 245

Answers (1)

cigien
cigien

Reputation: 60218

As soon as you provide a custom constructor for a class, the default constructor (the 0 argument constructor) is no longer synthesized. You need to reinstate it manually, like this:

class Stitcher {
  Stitcher() = default;
  // ...
};

Upvotes: 2

Related Questions