[英]begin() method declaration in Mat class opencv
While looking at opencv reference manual for using the begin() method, I came to the following declaration: 在查看有关使用begin()方法的opencv参考手册时,我来到了以下声明:
template<typename _Tp> MatIterator_<_Tp> Mat::begin()
I am not very good at C++, I was just wondering what "MatIterator" is and what's with the whole use of "_" ? 我不太擅长C ++,我只是想知道“ MatIterator”是什么,以及“ _”的整个用法是什么? (does it have any special meaning in C++)
(在C ++中它有什么特殊含义)
The only special meaning attached to an underscore in C++ is that names like _Tp
with underscore followed by another underscore or a capital letter are reserved for the implementation. 在C ++中,下划线所附加的唯一特殊含义是,
_Tp
名称, _Tp
在其后带有另一个下划线或大写字母,以供实现。
A trailing underscore (like in MatIterator_
) is often used to signify class members. 尾随的下划线(例如在
MatIterator_
)通常用于表示类成员。
From the looks of things, MatIterator_
is a type, apparently used as an iterator over a matrix. 从外观
MatIterator_
, MatIterator_
是一种类型,显然用作矩阵上的迭代器。
As to the declaration as a whole, it looks like: 至于整个声明,它看起来像:
"template" "<" template-parameters ">" return-type *function-name* "(" function-parameters ")" “ template”“ <” template-parameters “>” 返回类型 * function-name *“(”“ function-parameters ”)“
where: 哪里:
template-parameter is either class
or typename
followed by an arbitrary name (it can also be a non-type template parameter or a template template parameter, but we won't go into them, since this code isn't using either). template-parameter可以是
class
或typename
后跟任意名称(它也可以是非类型模板参数或模板模板参数,但由于本文未使用任何代码,因此我们不再赘述)。 When you instantiate the template, this name will signify the type over which it was instantiated. 实例化模板时,此名称将表示实例化模板的类型。
return-type is just some type that will be the type returned by the function. return-type只是某种类型,它将是函数返回的类型。 In this case, it depends on the template parameter, so it's saying "for some type
_Tp
, this will return a type called MatIterator<_Tp>
". 在这种情况下,它取决于template参数,因此它说“对于某些类型
_Tp
,这将返回称为MatIterator<_Tp>
的类型”。
function-name is just the name of the function you're defining. function-name只是您要定义的函数的名称。 In this case, it's a member function, so it's of the form "class-name :: member-name".
在这种情况下,它是成员函数,因此形式为“类名::成员名”。
function-parameters is empty in this case, so we won't got into it either. 在这种情况下, function-parameters为空,因此我们也不会考虑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.