minDist(100) 和这段代码中的大括号是什么意思
What does minDist(100) and the curly braces in this piece of code mean?
我刚刚遇到了一段让我感到困惑的代码。它是一个头文件,用于定义一个名为 ColorDetector 的类。私人部分如下:
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]);
}
这是这个类的公开声明,让我感到困惑:
public:
// empty constructor
ColorDetector() : minDist(100) {
// default parameter initialization here
target[0]= target[1]= target[2]= 0;
}
我不太清楚这个构造函数中的语法。mindset(100) 在这里是什么意思,为什么目标数组写在大括号内?我用关键字"默认构造函数"和"默认参数"搜索谷歌,但没有找到相关的文章。有人可以告诉我这段代码的确切含义吗?
这个类
这是成员初始化列表,请参阅 http://en.cppreference.com/w/cpp/language/initializer_list
相关文章:
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 标准 N3337 5.2.10 第 7 条中的C++"类型"是什么意思?
- "类模板示例<int>;"语句对 C++11 是什么意思?
- 线应该是什么意思
- "CID"在AT+HTTPPARA= "CID" ,1中是什么意思
- 表达式"b=(b-x)&x"是什么意思?
- 这个表达是什么意思?
- 此代码验证公式是什么意思?
- 跟踪日志中的T.11803()是什么意思?
- 这个额外的关键字在这个 c++ 类声明中是什么意思?
- * 和 ** 在 C++ 函数声明中是什么意思?
- _T("xyz")是什么意思?
- #define Dbg(fmt,..) (0) 是什么意思? 警告:表达式无效
- 这行代码到底是什么意思?
- 在命名空间名称之前加上 :: 是什么意思?
- 从字符数组的元素中减去'a'是什么意思
- "friend"关键字在C++中是什么意思?
- 减法中的"0"是什么意思?
- 字符数组前面的加号是什么意思?
- 这里的字符串函数是什么意思