Need a project done?

C++ Programming Developer

Search This Blog

Built in Stack in C++ - STL

#include "stdafx.h"
#include <iostream>
#include <stack>

using namespace std;

int main(int argc, _TCHAR* argv[])
{
stack<int> st;
st.push(1);
cout << "Pushed: " << st.top() << endl;
st.push(2);
cout << "Pushed: " << st.top() << endl;
st.push(3);
cout << "Pushed: " << st.top() << endl << endl;
while (!st.empty())
{
cout << "Emptying..." << endl;
st.pop();
}
//cout << "Stack top now: " << st.top() << endl;
}

No comments:

Post a Comment

"Don't let anyone ever make you feel like you don't deserve what you want."