I'm not sure what the following class does that we have a class example in the following code operator () in this case What does it do? I did not get much * (starting + first) and pretty much the complete return expression as to what is being evaluated. Any help would be great. Thanks!
// index index - interface for index compares class template #ifndef_INDEXCOMPARE_H_ #define _INDEXCOMPARE_H_ #pragmaOnce the template & lt; Class random_iterator & gt; Index Comparair (public): Index Comparair (Random_Eaterator Start, Random_itator and End): Start (Start), End (End) {} ~ Index Comparison () {} Balls Operator () (unsigned first Intex, unsigned int sec) Return (* + first) & lt; * (Start + second)); } Private: launch random_iterator; Random indicator; }; #endif
If you are asking that operator () It allows you to call the object like a function, for example see.
If you are asking what works in your example, then it is comparing the values of two elements specified by the index passed in the function. Start + first indicator refers to start , similarly start + second . * (start + first) gets value at that place.
You can use this class with any STL container (which supports random access) for example, you can use it with a vector like this:
vector & lt; Int & gt; Vec; / * Add some elements here / Index Comparrier & lt; Vector & lt; Int & gt; :: Iterator & gt; Compare (vec.begin (), vec.end ()); For example, vec [2] and compare values of vec compare compare (2, 5) 5] .
Comments
Post a Comment