stl stack使用...

#include <cstdlib> #include <iostream> #include <stack> using namespace std; typedef struct _NODE { string str; int id; _NODE(string str, int id) : str(str), id(id){}; friend ostream& operator << (ostream &os, const _NODE &nod) { return os << "(" << nod.id << ", " << nod.str << ")" << endl; } }NODE; int main(int argc, char *argv[]) { stack<NODE> stac; for(int i=0; i<10; i++) { NODE temp("string", i); stac.push(temp); } while(!stac.empty()) { cout << stac.top(); stac.pop(); } system("PAUSE"); return EXIT_SUCCESS; }  

你可能感兴趣的:(String,struct,OS,System,include)