I am implementing a Visual C++ project and it use Windows forms. I need to use C++ stack and I used stack<>. But it gives this error. I include #include <stack> and using namespace std; Before adding using namespace std; it says undeclared identifier. But after adding that it gives this error. I am new to C++. Can anyone explain me why this happens. Thanks…!
Part of my Code:
stack<int> TA;
stack<int> TB;
stack<int> TC;
void move_a_to_b(){
if(TB.top() < TA.top()){
B[index_of_b + 1]->Image = A[index_of_a]->Image;
B[index_of_b + 1]->Visible = true;
A[index_of_a]->Visible = false;
index_of_a--;
index_of_b++;
TB.push(TA.top());
TA.pop();
}
else
MessageBox::Show("Invalid Move","Error",MessageBoxButtons::OK,MessageBoxIcon::Exclamation);
}
I found the solution. This happens because of I am using unmanaged version of
stackwith managed version. the stack must not be initialized with thenewkeyword.