How to map CString to Class
-
Sir, I am developing an which maps CString as the key and maps to the class. For that I am using this code. in Person.h" CPerson { private: int age; public: CPerson (); CPerson (int a){ age = a; } } And in "FileView.cpp" CMapStringToOb map; CPerson one ; //one = new CPreson(); map.SetAt( "Bart", one ); This gives me an error. Pls help me with a solution . Regards
-
Sir, I am developing an which maps CString as the key and maps to the class. For that I am using this code. in Person.h" CPerson { private: int age; public: CPerson (); CPerson (int a){ age = a; } } And in "FileView.cpp" CMapStringToOb map; CPerson one ; //one = new CPreson(); map.SetAt( "Bart", one ); This gives me an error. Pls help me with a solution . Regards
use std::map instead. Then you can do this: myCoolMap["Bart"] = one; I suspect the problem though is that your class needs a copy constructor and/or operator = in order for this to work. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
Sir, I am developing an which maps CString as the key and maps to the class. For that I am using this code. in Person.h" CPerson { private: int age; public: CPerson (); CPerson (int a){ age = a; } } And in "FileView.cpp" CMapStringToOb map; CPerson one ; //one = new CPreson(); map.SetAt( "Bart", one ); This gives me an error. Pls help me with a solution . Regards
Either use the template version of
CMap
(e.g.CMap<CString, LPCTSTR, CPerson*, CPerson*>
) inafxtempl.h
, or deriveCPerson
fromCObject
. Stability. What an interesting concept. -- Chris Maunder