473,395 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

template declaration while passing Iterator as an argument

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
1 1189
dev7060
636 Expert 512MB
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

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

Similar topics

6
by: Mike Alexeev | last post by:
What is the correct syntax for default values to member function templates? Here is my example: 1 struct A 2 { 3 typedef int typeA; 4 }; 5 6 struct...
5
by: nifsmith | last post by:
Hi I am trying to learn about Queues and use templates at the same time. I have written the following code and I am getting a link error, stating "unresolved external symbol, "int__cdecl...
6
by: blueblueblue2005 | last post by:
Hi, below is the code I copy from c++ tutorial, it is about template specialization, but when I compile, I got error message: error: template-id `module<>' for `int mypair<int>::module()' does...
2
by: Alex Buell | last post by:
This is what I'm trying to compile with GCC 3.4.4 under Linux. The error I'm getting is: g++ -s -O3 -Wall class2.cc -o class2 class2.cc:25: error: template-id `uppercase<>' for `char...
3
by: chriscorbell | last post by:
I'm curious about what appears to be a restriction on using an STL container inside a user-defined template, esp. using an iterator to such a container. It's not clear to me if this is a general...
4
by: nutty | last post by:
Dear group, I tested this code in a 4.x gcc, MSVC 8.0, 7.1 and comeau in strict and relaxed mode. It compiles in MSVC and relaxed comeau, but fails in gcc 4.x and strict comeau It seems...
4
by: lutorm | last post by:
Hi all, I'm having a problem writing template functions that take vector<T>::iterator as arguments and I'm sure you guys can set me straight. Like this: #include<vector> using namespace std; ...
2
by: Joseph Turian | last post by:
I have a class Feature defined, which is a kind of Vocab: template <class T, unsigned I> class Vocab : boost::totally_ordered<Vocab<T,I { public: Vocab(); Vocab(const T& t); template<typename...
2
by: Rahul | last post by:
Hi Everyone, we use the following in the template declaration, template <class T> template<typename T> Is it that typename is preferred as it can be used for all types, where as class...
7
by: utab | last post by:
Dear all, I was experimenting with a template taking two iterators for the range of a vector.(Perhaps, it is sth simple and I am missing it because it is a late hour.) I ran into problems in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.