1: // Created by Frank M. Carrano and Timothy M. Henry. 2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey. 4: // Listing C8-1. 6: #include <iostream> 7: #include <stack> 8: int main() 9: { 10: std::stack<int> aStack; 11: 12: // Right now, the stack is empty 13: if (aStack.empty()) 14: 15: std::cout << "The stack is empty." << std::endl; 16: for (int j = 0; j < 5; j++) 17: aStack.push(j); // Places items on top of stack 18: 19: while (!aStack.empty()) 20: { 21: std::cout << aStack.top() << " "; 22: aStack.pop(); 23: } // end while 24: 25: return 0; 26: } // end main