Question about function template

  • Thread starter Thread starter chrisben
  • Start date Start date
C

chrisben

Here are sample codes from Thinking in C++ Vol I, page 776

// A function template:
template<class Iter>
void drawAll(Iter start, Iter end) {
while(start != end) {
(*start)->draw();
start++;
}
}

What I do not understand is line
(*start)->draw();

If Iter is a pointer, should that be start->draw(), instead of (*start)?
And if using (*start), assuming start is a pointer, after the dereference,
should it be
(*start).draw()?

Beginner in C++. Thanks for your time

Chris
 
chrisben said:
Here are sample codes from Thinking in C++ Vol I, page 776

// A function template:
template<class Iter>
void drawAll(Iter start, Iter end) {
while(start != end) {
(*start)->draw();
start++;
}
}

What I do not understand is line
(*start)->draw();

If Iter is a pointer, should that be start->draw(), instead of (*start)?
And if using (*start), assuming start is a pointer, after the dereference,
should it be
(*start).draw()?

Beginner in C++. Thanks for your time

Chris:

Please don't multi-post.

This is a question about standard C++, nothing to do with dotnet, so it does not
belong here. Your question has been answered in vc.language.
 
Back
Top