(was) STL <map> question

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 4
Reputation: Flay is an unknown quantity at this point 
Solved Threads: 0
Flay Flay is offline Offline
Newbie Poster

Re: STL <map> question?

 
1
  #1
Sep 15th, 2006
I have a question about the map-question JoBe asked at the start of this post. I'm also trying to build a program using <map>, but when i compile i get error that point to code inside the MAP-file.

I saw your post here, and i tried your small program, but even then i get 2 errors inside the MAP-file, and also those warnings you asked about.
I don't know why i get those errors.
JoBe's code was:
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. typedef map<string, int, less<string> > maptype;
  10. maptype M;
  11.  
  12. M["Jan"] = 1234;
  13. M["Piet"] = 9999;
  14. M["Piet"] = 3456;
  15. M["Klaas"] = 5678;
  16.  
  17. for(maptype::iterator i = M.begin(); i != M.end(); ++i)
  18. cout<< (*i).first <<" "<< (*i).second <<endl;
  19.  
  20. cout<<"Press any key to continue!\n";
  21. cin.get();
  22.  
  23. return 0;
  24. }
When i make a new project (win32 console app) and i compile it, i get these 2 errors:

c:\program files\microsoft visual studio\vc98\include\map(16) : error C2143: syntax error : missing ';' before 'namespace'
c:\program files\microsoft visual studio\vc98\include\map(16) : error C2501: 'B' : missing storage-class or type specifiers

Anyone any idea why this happens?

TIA
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 147
Reputation: Grunt has a spectacular aura about Grunt has a spectacular aura about 
Solved Threads: 12
Grunt's Avatar
Grunt Grunt is offline Offline
Junior Poster

Re: STL <map> question?

 
1
  #2
Sep 15th, 2006
The code is fine and should work. Try rebuilding solution.
The key to eliminating bugs from your code is learning from your mistakes.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 4
Reputation: Flay is an unknown quantity at this point 
Solved Threads: 0
Flay Flay is offline Offline
Newbie Poster

Re: STL <map> question?

 
0
  #3
Sep 15th, 2006
Originally Posted by Grunt View Post
The code is fine and should work. Try rebuilding solution.
i rebuiled it a couple of times, but i still got the errors.
i believe you guys when you say it works, but i don't get why i get these errors. Maybe a fault in my Options or something? i don't know
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: (was) STL <map> question

 
1
  #4
Sep 15th, 2006
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 65
Reputation: GloriousEremite will become famous soon enough GloriousEremite will become famous soon enough 
Solved Threads: 14
GloriousEremite GloriousEremite is offline Offline
Junior Poster in Training

Re: (was) STL <map> question

 
1
  #5
Sep 15th, 2006
Maybe there's a problem with your compiler/IDE installation or with the header files.

Also, make sure your code is being compiled as C++ and not C
"What are the roots that clutch, what branches grow
out of this stony rubbish?"
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC