I use the compiler class when using the map class and wrote the following simple program to highlight the error:
1 #include <string>
2 #include <map>
3
4 using namespace std;
5
6 int main()
7 {
8 map<string, string> testmap;
9
10
11 testmap["one"] = 11;
12 testmap["two"] = 22;
13 testmap["zero"] = 0;
14 // testmap["zero"] = 10;
15
16 return 0;
17 }
I get the following compilation error:
g++./test.cc. /test.cc: 'int main()':. /test.cc:13:23: : 'operator =' 'testmap.std:: map < _Key, _Tp, _Compare, _Alloc > :: operator [], std:: basic_string, std:: less > , > std:: allocator, std:: basic_string → > ((* std:: basic_string (((const char *) "zero" ), ((const std:: allocator) (& std:: allocator()))))) = 0 '. /test.cc:13:23: : : , /usr/include/c ++/4.7/string:54:0, from./test.cc:1: /usr/include/c ++/4.7/bits/basic_string.h:543:7: note: std:: basic_string < _CharT, _Traits, _Alloc > & std:: basic_string < _CharT, _Traits, _Alloc > :: operator = (const std:: basic_string < _CharT, _Traits, _Alloc > &) [with > _CharT = char; _Traits = std:: char_traits; _Alloc = std:: allocator; std:: basic_string < _CharT, _Traits, _Alloc >= std:: basic_string] /usr/include/c ++/4.7/bits/basic_string.h:551:7: note: std:: basic_string < _CharT, _Traits, _Alloc > & std:: basic_string < _CharT, _Traits, _Alloc > :: operator = (const _CharT *) [ _CharT = char; _Traits = > std:: char_traits; _Alloc = std:: allocator; std:: basic_string < _CharT, _Traits, _Alloc >= std:: basic_string] /usr/include/c ++/4.7/bits/basic_string.h:562:7: note: std:: basic_string < _CharT, _Traits, _Alloc > & std:: basic_string < _CharT, _Traits, _Alloc > :: operator = (_ CharT) [ _CharT = char; _Traits = std:: char_traits; _Alloc = std:: allocator; std:: basic_string < _CharT, _Traits, _Alloc >= std:: basic_string]
:
1. , "" - 11 22 . , , . : testmap [ "one" ] = 11;
11, 22 , 0 .
, . , / string. -, , , .
.
,
.