I am trying to create a stringtable class which is a simple unordered_map & Lt; String, string & gt; , and the array index operator '['] is overloaded to work to reach the map; However, the compiler will tell me that unless I try to use it, I do not have to define the overloaded operator. My code is as follows:
CStringTable.h
< Pre> #include & lt; String & gt; # Include & lt; Fstream & gt; # Include & lt; Tr1 / unordered_map & gt; Class CStringTable {public: bool load (const char * filename); Inline contact four characters * operator [] (const char * key); Get Const char * (const char * key); Private: std :: tr1 :: unordered_map & lt; Std :: string, std :: string & gt; * M_StringMap; }; : String skey = key; Return (* m_StringMap) [sKey] .c_str (); } I try to use the map as follows:
(* m_cStringTable) [msgkey] An indicator for a frequency of m_cStringTable CStringTable class and msgKey one const char *
Does anyone tell me why this will not work?
About inline keywords, view the compiler in the .h file as well as the body of that method. the wanted. So either move operator's implementation from .cpp file to .h file, or include the operator's body in class declaration.
Comments
Post a Comment