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

weird parse error in template class

Hi everybody,

maybe you can give me a hint about the following problem:

I have a simple template class that stores pointers to variables in a map,
and publish the actual values when requested.

template<typename T>
class HighLevelMonitor {

public:

void declareMyVar(string, T*);
void publishAll();

private:

map<string, T*> monVarContainer;

};
In the following implementation, I get a " parse error before = " when
compiling coming form the line:
map<string, T*>::iterator it = monVarContainer.begin();

\*-------------------------------------------------*\
template <typename T>
void HighLevelMonitor<T>::publishAll()
\*-------------------------------------------------*\
{
cout <<"------------publishAll()------------" << endl;

map<string, T*>::iterator it = monVarContainer.begin();

for(; it != monVarContainer.end(); it++ ){

cout << it->first << " = " << *(it->second) << endl;
}
cout <<"---------------------------------------" << endl;
}
Any clue about why I get this error??
Regards

Manuel


--
================================================== ======================
Manuel Diaz-Gomez | ATLAS Bldg. 32/SB-008 tel. +41 22 76 76304
CERN EP Division
CH-1211 Geneva 23
SWITZERLAND
================================================== ======================
Jul 22 '05 #1
1 1582
Manuel Maria Diaz Gomez wrote:
Hi everybody,

maybe you can give me a hint about the following problem: ....
map<string, T*>::iterator it = monVarContainer.begin();
typename map<string, T*>::iterator it = monVarContainer.begin();


Any clue about why I get this error??


When parsing a template, the compiler can't tell if what you're
referencing is a type or not and so needs some help. It is required by
the standard that you use "typename" to prefix the type expression when
the template is unable to determine the type.
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave O'Hearn | last post by:
This is a stripped down example that duplicates the problem I am having. If I do it with concrete types, I can access the set's iterator type correctly. If I make a template with generic types, I...
1
by: David M Noriega | last post by:
Ok I'm no programmer but have done it in the past. I am trying to build a program from its source, its called Juk. It needs the kde bindings for GStreamer. I found them using CVS. So no I must...
4
by: Roger Leigh | last post by:
In a header, I have the following class template: template<typename _ListItem> class SimpleListItemConvert : public pqxxobject::RowConvert<_ListItem> { }; However, this won't compile: $...
2
by: James Aguilar | last post by:
There is a syntax error in this code that I can't figure out. template <class T> std::ostream &operator <<(std::ostream &os, PriorityQueue<T> &q) { using namespace std; //g++ doesn't like...
2
by: ken | last post by:
the test code is : ///////////////////////////////////////////////////////////////// #include <stdlib.h> #include <stdio.h> class CA { public:
2
by: alice | last post by:
Hi, When I compiles the following program with g++, it gives the following output: # g++ -o list list.C list.C: In function `int main()': list.C:116: jump to case label list.C:110: crosses...
11
by: JRough | last post by:
I'm trying to use output buffering to cheat so i can print to excel which is called later than this header(). header("Content-type: application/xmsdownload"); header("Content-Disposition:...
3
by: Leighya | last post by:
Im currently working on this xml file but when i load it to Mozilla, i got an error "Error Loading Stylesheet: Xpath parse failure: invalid variable name" It loads on IE properly. Only with the...
2
by: TamaThps | last post by:
Hi, I'm using visual studio 2008 and normally when I get an error it shows what line it is on and which file etc. The error I'm getting I don't know how to solve or even what the problem is. This...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.