Home > Back-end >  For the problem whether function parameter name
For the problem whether function parameter name

Time:10-07

In the STL source of iterator. H section, see the two functions, don't understand the difference between the two functions are very?
 template & lt; The class _Iter & gt; 
The inline typename iterator_traits & lt; _Iter & gt; : : iterator_category
__iterator_category (const _Iter & amp;)
{
Typedef typename iterator_traits & lt; _Iter & gt; : : iterator_category _Category;
Return _Category ();
}
The template & lt; The class _Iter & gt;
The inline typename iterator_traits & lt; _Iter & gt; : : iterator_category
Iterator_category (const _Iter & amp; __i) {return __iterator_category (__i); }


I want to ask the question is; Two function declarations are nearly the same, in addition to the second a function parameter __i, could see, the parameter is not used by the body of the function, what is the purpose of this definition?

CodePudding user response:

__iterator_category (const _Iter & amp;)
Iterator_category (const _Iter & amp; __i)

Function name is different, this is two different function, as for the parameter name, just when this parameter is used in a function, parameters can be anonymous, the parameter name does not affect the function definition,

CodePudding user response:

Ha ha, clattering upstairs,
  • Related