c++ 모호한 기호입니다. 라고 오류가 떠요...
글쓴이: pentas / 작성시간: 일, 2012/10/07 - 1:10오후
'move' 가 모호한 기호입니다. 라고 뜨는데 어떻게 해야하나요??
move는 stuct offsets 이고
오류나는 부분은 void path() 에 잇는
int g = i + move[d].a;
int h = j + move[d].b;
이 부분입니다.
#include <iostream>
#include <stack>
using namespace std;
const int MAXSIZE=100; // up to 100 by 100 maze allowed
bool maze[MAXSIZE+2][MAXSIZE+2] = { 0 } ;
bool mark[MAXSIZE+1][MAXSIZE+1] = { 0 } ;
enum directions { N, NE, E, SE, S, SW, W, NW };
struct offsets
{
int a, b;
} move[8] = { -1,0, -1,1, 0,1, 1,1, 1,0, 1,-1, 0,-1, -1,-1 };
struct Items {
Items(int xx=0, int yy=0, int dd=0): x(xx), y(yy), dir(dd) {}
int x, y, dir;
};
template <class T>
ostream& operator<< (ostream& os, stack<T>& s) {
// 스택의 내용을 역순으로 출력
// 구현방법=내용을 하나씩 꺼내 다른 임시 스택에 넣어 저장한
// 후, 최종적으로 그 임시 스택에서 하나씩 꺼내 출력하면 됨
os<<""top=<<s.top<<endl;
for(int i=0;i<=s.top;i++)
os<<i<<":"<<s.stack[i]<<endl;
stack<T> s2;
while(!s.empty()) {
s2.push(s.top());
s.pop(); }
while(!s2.empty()) {
os<<"->"<<s2.top();}
return os;
}
ostream& operator<<(ostream& os, Items& item)
{
static int count = 0; // 5개의 Items가 출력될 때마다 줄바꾸기위해
os << "(" << item.x << "," << item.y << ")";
count++; if ((count % 5) == 0) cout << endl;
return os;
}
void Path(const int m, const int p)
{
mark[1][1] = 1;
stack<Items> stack; // C++ STD stack을 이용하라
Items temp(1, 1, E);
stack.push(temp);
while (!stack.empty())
{
temp = stack.top();
stack.pop();
int i= temp.x; int j= temp.y; int d = temp.dir;
while(d<8) // 앞으로 이동
{
int g = i + move[d].a;
int h = j + move[d].b;
if((g==m)&&(h==p)){//출구도착
cout << stack;
temp.x = i; temp.y = j; cout << " -> " << temp;
temp.x = m; temp.y = p; cout << " -> " << temp << endl;
return;
}
if((!maze[g][h])&&(!mark[g][h]))
{
mark[g][h]=1;
temp.x=i; temp.y=j; temp.dir=d+1;
stack.push(temp); //스택에 삽입
i=g; j=h; d=N; //(g,h)로 이동
}
else d++; //다음방향으로 시도
} //end of while(d<8)
} //end of while(!stack.empty())
cout<<"No path in maze."<<endl;
}
void getdata(istream& is, int& m, int & p)
{ // 자료화일을 읽어들여 maze에 저장한다.
is >> m >> p;
for (int i = 0; i < m+2; i++) { maze[i][0] = 1; maze[i][p+1] = 1; }
for (int j = 1; j <= p; j++) { maze[0][j] = 1; maze[m+1][j] = 1; }
for (int i = 1; i <= m; i++)
for (int j = 1; j <= p; j++)
is >> maze[i][j];
}Forums:


offsets 구조체 선언에서 선언 후 사용을 바로
offsets 구조체 선언에서 선언 후 사용을 바로 해도 되나요?
피할 수 있을때 즐겨라! http://melotopia.net/b
move가 이미 매크로나 함수 같은 거로 정의가
move가 이미 매크로나 함수 같은 거로 정의가 되어있네요.
저거만 바꾸시면 해결되지 않을까 하는데 아닌가요?
저는 이렇게 생각했습니다.
move를 ::move로 바꿔보세요. 그리고
move를 ::move로 바꿔보세요. 그리고 다음부터는 정확한 에러메시지를(출력된 에러를 그대로) 첨부해주세요.
std::move ?
using namespace std 가 있는 것을 보니 최신의 compiler 를 사용한 대가(?)가 아닐까요?
댓글 달기