By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 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
2 Weeks Ago #1
Share this Question
Share on Google+
1 Reply


P: 60
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.
2 Weeks Ago #2

Post your reply

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