//: C07:Stack1.cpp // From "Thinking in C++, Volume 2", by Bruce Eckel & Chuck Allison. // (c) 1995-2004 MindView, Inc. All Rights Reserved. // See source code use permissions stated in the file 'License.txt', // distributed with the code package available at www.MindView.net. // Demonstrates the STL stack. #include #include #include #include #include #include using namespace std; // Rearrange comments below to use different versions. typedef stack Stack1; // Default: deque // typedef stack > Stack2; // typedef stack > Stack3; int main() { ifstream in("Stack1.cpp"); Stack1 textlines; // Try the different versions // Read file and store lines in the stack: string line; while(getline(in, line)) textlines.push(line + "\n"); // Print lines from the stack and pop them: while(!textlines.empty()) { cout << textlines.top(); textlines.pop(); } } ///:~