简体   繁体   中英

begin() method declaration in Mat class opencv

While looking at opencv reference manual for using the begin() method, I came to the following declaration:

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 "_" ? (does it have any special meaning in 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.

A trailing underscore (like in MatIterator_ ) is often used to signify class members.

From the looks of things, MatIterator_ is a type, apparently used as an iterator over a matrix.

As to the declaration as a whole, it looks like:

"template" "<" template-parameters ">" return-type *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). 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. 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> ".

function-name is just the name of the function you're defining. 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.

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