Hi,
I'm getting started with STL, and am stuck at creating a map
container. I checked one of the texts and found a code in there. To
make it simple, i wrote the following:
#include <iostream.h>
#include <string.h>
#include <map>
typedef std::map<string,string,std::less<string>> mymap;
int main()
{
mymap somemap;
return 0;
}
This gives me 6 error messages, an a warning. Could anyone point me
the mistake....i've been to grasp the topic for two days now!
Initially i thought i might not be using string properly, so i changed
the code typedef to
typedef std::map<int,int, std::less<int>> mymap;
This give me an error saying :
C:\Documents and Settings\Ash\Desktop\Maps\MuliMap\Main.cpp(4) : error
C2146: syntax error : missing ',' before identifier 'mymap'
C:\Documents and Settings\Ash\Desktop\Maps\MuliMap\Main.cpp(4) : :
error C2065: 'mymap' : undeclared identifier
C:\Documents and Settings\Ash\Desktop\Maps\MuliMap\Main.cpp(4) : error
C2143: syntax error : missing '>' before ';'
C:\Documents and C:\Documents and
Settings\Ash\Desktop\Maps\MuliMap\Main.cpp(4) : warning C4091:
'typedef ' : ignored on left of 'class std::map' when no variable is
declared
Thanks,
Ash 2 2316
<ash> wrote in message news:6h********************************@4ax.com... Hi,
I'm getting started with STL, and am stuck at creating a map container. I checked one of the texts and found a code in there. To make it simple, i wrote the following:
#include <iostream.h>
Non-standard header file, use <iostream> (without a .h)
#include <string.h>
This is a valid header file, but it doesn't declare the std::string class
which is what you are thinking it does, instead it declares the C string
handling routines. Use <string> instead (again without a .h)
#include <map>
typedef std::map<string,string,std::less<string>> mymap;
std::less is unecessary, but string is wrong, it should be std::string. Try
this
typedef std::map<std::string,std::string> mymap; int main() { mymap somemap; return 0; }
This gives me 6 error messages, an a warning. Could anyone point me the mistake....i've been to grasp the topic for two days now!
Don't know what book you are reading, doesn't it have any syntactically
valid programs in it?
You need to use the correct header files (no C++ header files have .h in
them)
You need to remember std::
You should forget about std::less (at least for now).
john
ash wrote: Hi,
I'm getting started with STL, and am stuck at creating a map container. I checked one of the texts and found a code in there. To make it simple, i wrote the following:
#include <iostream.h>
#include <iostream> #include <string.h>
#include <string>
[<string.h> is a C header that contains the prototypes for things like
strcmp(), strcpy(), and the like -- *not* C++ std::string]
#include <map>
typedef std::map<string,string,std::less<string>> mymap;
typedef std::map<std::string,
std::string,
std::less<std::string> > mymap;
[the space between the enclosing `>'s is necessary] int main() { mymap somemap; return 0; }
This gives me 6 error messages, an a warning. Could anyone point me the mistake....i've been to grasp the topic for two days now!
Initially i thought i might not be using string properly, so i changed the code typedef to
typedef std::map<int,int, std::less<int>> mymap;
This give me an error saying : C:\Documents and Settings\Ash\Desktop\Maps\MuliMap\Main.cpp(4) : error C2146: syntax error : missing ',' before identifier 'mymap' C:\Documents and Settings\Ash\Desktop\Maps\MuliMap\Main.cpp(4) : : error C2065: 'mymap' : undeclared identifier C:\Documents and Settings\Ash\Desktop\Maps\MuliMap\Main.cpp(4) : error C2143: syntax error : missing '>' before ';' C:\Documents and C:\Documents and Settings\Ash\Desktop\Maps\MuliMap\Main.cpp(4) : warning C4091: 'typedef ' : ignored on left of 'class std::map' when no variable is declared
HTH,
--ag
--
Artie Gold -- Austin, Texas This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave |
last post by:
After following Microsofts admonition to reformat my system before doing a
final compilation of my app I got many warnings/errors upon compiling an rtf
file created in word. I used the Help...
|
by: Tom |
last post by:
A question for gui application programmers. . .
I 've got some GUI programs, written in Python/wxPython, and I've got
a help button and a help menu item. Also, I've got a compiled file
made with...
|
by: wukexin |
last post by:
Help me, good men. I find mang books that introduce bit "mang header
files",they talk too bit,in fact it is my too fool, I don't learn it, I have
do a test program, but I have no correct doing...
|
by: Colin J. Williams |
last post by:
Python advertises some basic service:
C:\Python24>python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
With...
|
by: Corepaul |
last post by:
Missing Help Files
When I enter "recordset" as the keyword and search the Visual Basic Help index,
I get many topics of interest in the resulting list. But there isn't any
information available...
|
by: Steve |
last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp
My expectation is that a developer using my DLL would be able to access this help file during his development time...
|
by: Mark |
last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my
home computer has an abbreviated help screen not 2% of the help on my laptop.
All the settings look the same on both...
|
by: JonathanOrlev |
last post by:
Hello everybody,
I wrote this comment in another message of mine, but decided to post it
again as a standalone message.
I think that Microsoft's Office 2003 help system is horrible, probably...
|
by: trunxnirvana007 |
last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
'UPGRADE_WARNING: Couldn't resolve...
|
by: hitencontractor |
last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003.
I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About.
The application...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |