Question about function template

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
 
D

David Wilkinson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top