재귀함수? 이용해서 하노이의탑 솔루션 프린트해주는게 과제인데요



void solve::print_solution(int n, stack from, stack to, stack by, int i1, int i2)

{

if (n == 1)

{

move(from, to, i1, i2);

}

else

{

print_solution(n - 1, from, by, to, i1, i2);

print_solution(n - 1, by, to, from, i1, i2);

}

}

void solve::move(stack from, stack to, int i1, int i2)

{

if (from.data[from.top] > to.data[to.top])

{

cout << "옮기려는 원판의 크기가 더 큽니다.";

}

if (from.is_empty())

{

cout << "옮겨오려는 기둥이 비어있습니다";

}

else if (from.data[from.top] < to.data[to.top] || to.is_empty())

{

cout << "moving disk " << from.data[from.top] << " from pillar " << i1 << " to pillar " << i2 << endl;

to.push(from.pop());

}

}


요기서 프린트솔루션에서 무브함수 불러와서 무브함수에서 푸쉬,팝 해줬는데 그 결과가 반영이 안되고 원래 스택으로 돌아와요.. 

왜때문이죠?

일단 재귀방법이 틀렸는지는 신경쓰지 마시고 왜 초기화되는지 원인좀 알려주세요..