Ami*_*mar 0 c++ stl compiler-errors map
在下面的程序中使用MAP会产生一些编译器错误.没有得到他们的意思.
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
using namespace std;
char maze [61][61], q;
int n , m , i , j , x , y;
map < char , char > left ;
map < char , char > right ;
char orient ;
int main(){
left ['N'] = 'W' ;
left ['E'] = 'S';
left['S'] = 'E';
left['W'] = 'N';
right['N'] = 'E';
right['E'] = 'S';
right['S'] = 'W';
right['W'] = 'N';
scanf( "%d %d" , &n , &m) ;
for ( i = 0 ; i < n ; i++)
scanf("%s", maze[i]);
scanf("%d %d" , &x ,&y);
orient = 'N' ;
x = x - 1 ; y = y - 1 ;
return 0 ;
}
Run Code Online (Sandbox Code Playgroud)
获得编译错误如:
prog.cpp: In function ‘int main()’:
prog.cpp:15:1: error: reference to ‘left’ is ambiguous
left['N'] = 'W';
prog.cpp:9:21: note: candidates are: std::map<char, char> left
map < char , char > left ;
In file included from /usr/include/c++/4.8/ios:42:0,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from prog.cpp:1: /usr/include/c++/4.8/bits/ios_base.h:916:3:
note: std::ios_base& std::left(std::ios_base&)
left(ios_base& __base)
Run Code Online (Sandbox Code Playgroud)
有什么问题可以指出,这意味着什么?有关详细信息,请访问:http:
//ideone.com/CqBiS0