Fairly straightforward question. I have a map that I wish to initialize by calling a function like so:
map<string, int> myMap;
myMap = initMap( &myMap );
map<string, int> initMap( map<string, int> *theMap )
{
/* do stuff... */
However, the compiler is moaning. What’s the solution to this?
EDIT 1:
I’m sorry, but I screwed up. The code was correctly written with *theMap, but when I posted the question, I failed to notice that I had omitted the *. So to answer the comment, the error message I get is:
1>Roman_Numerals.cpp(21): error C2143: syntax error : missing ';' before '<'
which is thrown at
map<char, int> initMap( map<char, int> *numerals );
using VC++ 2010 Express and the same error again when I define the function.
Either do:
or do:
i.e. let the function initialise the map you give it, or take the map the function gives you. You’re doing both (without a
returnstatement too!)I’d go for the first option.