简体   繁体   中英

What does minDist(100) and the curly braces in this piece of code mean?

I've just met a piece of code that made me confused. It's a header file that defines a class named ColorDetector. The private part is as follows:

class ColorDetector {
  private:
  // minimum acceptable distance
  int minDist;

  // target color
  cv::Vec3b target;

  // image containing resulting binary map
  cv::Mat result;

  // inline private member function
  // Computes the distance from target color.
  int getDistance(const cv::Vec3b& color) const {
     // return static_cast<int>(cv::norm<int,3>(cv::Vec3i(color[0]-target[0],color[1]-target[1],color[2]-target[2])));
      return abs(color[0]-target[0])+
                abs(color[1]-target[1])+
                abs(color[2]-target[2]);
  }

Here's the public declaration of this class that made me confused:

public:

  // empty constructor
  ColorDetector() : minDist(100) {

      // default parameter initialization here
      target[0]= target[1]= target[2]= 0;
  }

I am not quite clear about the grammar in this constructor here. What does mindset(100) mean here and why the target array is written within curly braces? I searched google with keyword "default constructor" and "default parameter" but found no relating articles. Can someone tell me the exact meaning of this piece of code here?

The class of this

这是成员初始化列表,请参见http://en.cppreference.com/w/cpp/language/initializer_list

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM