STL map with own Datatype

Dear all,

I’m trying to run this macro on the interpreter:

gROOT->ProcessLine("#include <map>");
gROOT->ProcessLine("#include <string>");
gROOT->LoadMacro("./MyClass.C");

std::map <std::string, MyClass> test;
MyClass h;
test["name"] = h;

but get the following error message, as long as I use the class MyClass and not a native datatype. (I’m using ROOT v5.11)

Error: Can't call map<string,MyClass,less<string>,allocator<pair<const string,MyClass> > >::operator[]((char*)0x96fe334) in current scope test.C:8:
Possible candidates are...
(in map<string,MyClass,less<string>,allocator<pair<const string,MyClass> > >)
Error: improper lvalue test.C:8:

Thank you for your help,
Manuel

Hi,

you need a dictionary for that. See Philippe’s PS on loader.C in the following posting:
root.cern.ch/phpBB2/viewtopic.ph … highlight=
That will fix it for you, too.

Cheers, Axel.