473,396 Members | 1,771 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,396 software developers and data experts.

Templates with Maps

5
So, I am trying to compile this file which has a template as follows:

Expand|Select|Wrap|Line Numbers
  1. using namespace std;
  2. template<class K, class T, class W>
  3. class AMI_cache_manager_static: public AMI_cache_manager_base {
  4.  
  5. private:
  6.     map<K,T> data_;
  7.     size_t current_size;
  8.     W writeout_;
  9.  
  10. public:
  11.     AMI_cache_manager_static(size_t capacity) : AMI_cache_manager_base(capacity, 0), writeout_() {
  12.         current_size = 0;        
  13.     }
  14.     ~AMI_cache_manager_static(){
  15.         map<K,T>::iterator it;
  16.         it = data_.begin();
  17.         while (it != data_.end()) {
  18.             writeout_(it->second);
  19.             it++;
  20.         }
  21.     }
Now, it's telling me there's an error in the map<K,T>::iterator it; section the error message being " ';' required before it " if I change map<K,T> to map<string,string> it works...

Thank You
Jul 19 '07 #1
3 1179
gpraghuram
1,275 Expert 1GB
So, I am trying to compile this file which has a template as follows:

Expand|Select|Wrap|Line Numbers
  1. using namespace std;
  2. template<class K, class T, class W>
  3. class AMI_cache_manager_static: public AMI_cache_manager_base {
  4.  
  5. private:
  6.     map<K,T> data_;
  7.     size_t current_size;
  8.     W writeout_;
  9.  
  10. public:
  11.     AMI_cache_manager_static(size_t capacity) : AMI_cache_manager_base(capacity, 0), writeout_() {
  12.         current_size = 0;        
  13.     }
  14.     ~AMI_cache_manager_static(){
  15.         map<K,T>::iterator it;
  16.         it = data_.begin();
  17.         while (it != data_.end()) {
  18.             writeout_(it->second);
  19.             it++;
  20.         }
  21.     }
Now, it's telling me there's an error in the map<K,T>::iterator it; section the error message being " ';' required before it " if I change map<K,T> to map<string,string> it works...

Thank You
r u using g++ compiler?
I also got smilar type of error when compiling it using g++.
There was a post in this forum sometime back which suggested to use typename when declaring it.
Better do a search in this forum.


Raghuram
Jul 20 '07 #2
algatt
5
r u using g++ compiler?
I also got smilar type of error when compiling it using g++.
There was a post in this forum sometime back which suggested to use typename when declaring it.
Better do a search in this forum.


Raghuram
Yes, actually that was the problem I simply added typename before the map and it worked.

Thanks
Jul 20 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
Compiles as originally written using Visual Studio.NET 2005.
Jul 22 '07 #4

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

Similar topics

4
by: Jeff Sandys | last post by:
I'm trying to write a mapping function for genealogy. I want to read a gedcom database and plot an icon at a geographic location based on a user's query. Can you help me find: 1) A python...
4
by: Stanimir Stamenkov | last post by:
I have this kind of construct: http://www.geocities.com/stanio/temp/usemap01.html (an IMG element using MAP described with AREA elements) I'm trying to make it more accessible and currently...
2
by: Old Monk | last post by:
Hi all, Say I have two maps m1 and m2. Both have key as std::string and value as long. m1 could hold entries like "abc" 123 "def" 456 m2 could have entries like
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
3
by: Sean | last post by:
Have you ever wanted to add the great features inherent in Google Maps? Here is how you do it. ============== == STEP ONE == ============== Create a new MS Access form called frmGoogleMap....
25
by: Ted | last post by:
I'm putting the posts that follow here (hopefully they will follow here!) because they were rejected in comp.lang.c++.moderated. It behooves anyone reading them to first read the the thread of the...
5
by: DrLex | last post by:
This is a really annoying thing to look up in Google because all pages that mention STL maps or vectors will most likely also contain the word "template". So maybe this question has been asked...
0
by: JonLT | last post by:
The STL has lists, maps, vectors(as in array), string ect, but what about vectors(as in vector), matrices, planes and the like, is there any standard math templates out there? Currently i'm just...
2
by: rn5arn5a | last post by:
I am not sure where I should have posted this question in this newsgroup. Please excuse me if I am wrong. Nowadays, a lot of websites have come with Maps (Google Maps being an example). Can...
3
by: Phil Stanton | last post by:
I have a button on a form which when pressed displays a google map of the address. Code is Private Sub Googlemap_Click() MakeURL ("") End Sub
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.