By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,711 Members | 2,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,711 IT Pros & Developers. It's quick & easy.

template declaration while passing Iterator as an argument

P: 1
Expand|Select|Wrap|Line Numbers
  1. template <typename Iterator>
  2.      void process(Iterator begin, Iterator end)
  3.      {
  4.          for (; itr != end; ++itr) {
  5.              process(*itr);
  6.          }
  7.      }

why i can't write


Expand|Select|Wrap|Line Numbers
  1.      void process(Iterator begin, Iterator end)
  2.      {
  3.          for (; itr != end; ++itr) {
  4.              process(*itr);
  5.          }
  6.      }
  7.  
  8.  
please explain
May 8 '19 #1
Share this Question
Share on Google+
1 Reply


dev7060
100+
P: 114
You mean like excluding the first line?

Template needs to be defined first so that the generic data types it's having can be used.
May 9 '19 #2

Post your reply

Sign in to post your reply or Sign up for a free account.