#include #include using namespace std; class myC { public: myC() : key(0), s("") {} myC(int ky, string str) : key(ky), s(str) {} //myC(const myC& c); // Copy constructor not req //void operator=(const myC& r); // op= not required int getKey() {return key;} void setKey(int k) {key = k;} string getString() { return s;} private: int key; string s; }; typedef stack myStack; int main () { string phrase[] = {"We're #1", "We try harder", "We placed", "We Lost"}; myStack s; myC c; int i; for (i = 1; i <= 4; i++) { c = myC(i, phrase[i-1]); s.push(c); } i = 1; while (!s.empty()) { c = s.top(); cout << "Element " << i++ << ": key = " << c.getKey() << ", s = " << c.getString() << "." << endl; s.pop(); } return 0; }