Passing a map by reference

All,
I have the following map in my method:

className::Initialise()
{

map<string, myClass*> myMap;

/* do some stuff here */

myClass myObject* = new myClass("Param1", "Param2");

myMap["UniqueIndex"] = myObject;

func1(myMap);

}

void func1(map<string, myClass*>& theMap)
{
do some stuff
}


This may sound like a real stoopid question here, but how do you pass myMap by reference!!

I'm getting a compiler error that states :

cannot convert parameter 1 from 'const std::map<_Kty,_Ty>' to 'std::map<_Kty,_Ty> *'

I'm not quite sure why it thinks that I declared myMap as a const std::map(...) when I haven't!

Cheers
[834 byte] By [DrunkenDisorderly] at [2007-11-20 11:11:01]
# 1 Re: Passing a map by reference
Show complete code with no extra dependencies/unknown. We should be able to copy that into an editor and compile it to get just your error message reported.
exterminator at 2007-11-9 1:25:16 >
# 2 Re: Passing a map by reference
All,
I have the following map in my method:Please take the time to post compilable code that produces the error. There are a lot of other errors in the code that you did post. We don't know whether those errors are a cause of the problem, or are typographical errors. Next time, please copy the code and paste it in the window, and do not type it in.

Here is an example of a complete piece of code that compiles as-is without any edits. This code compiles with no problems:

#include <map>
#include <string>

class myClass
{
};

class className
{
public:
void Initialise();
};

using namespace std;

void func1(std::map<string, myClass*>& theMap);

void className::Initialise()
{
map<string, myClass*> myMap;
myClass *myObject = new myClass;
myMap["UniqueIndex"] = myObject;
func1(myMap);
}

void func1(map<string, myClass*>& theMap)
{
}

There are no errors here.

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-9 1:26:18 >