// - "C shortcut tutorial" reading notes - Chapter 11 - Class (Part 4) // - Chapter 11 - Class // - 03/15/2006 Wed.//--computer LAB / / - Liwei
// - Program # 4 queuq # include
INT size = 3;
Class Queue {Int Sloc, Rloc; Int WHO;
PUBLIC: INT Q [3]; Queue (int ID); ~ queue (); void qput (int i); int rt QGet ();};
Queue :: queue (int ID) {rloc = Sloc = -1; q [0] = 0; WHO = ID; cout << "queue" << WHO << "Initialized./N";
}
Queue :: ~ queue () {cout << "Queue" << WHO << "DESTROYED./N";
Void queue :: qput (int i) {if (sloc == size) {cout << "Queue is full./N"; return;} Sloc ; Q [Sloc] = i;
}
INT Queue :: qget () {if (rloc == size) {cout << "queue underflow./N"; return 0;} rloc ; return q [rloc];
}
INT main () {Queue A (1), B (2); A.QPUT (10); B.QPut (19);
A.QPUT (20); B.QPut (1);
A.QPUT (999); B.QPut (999);
COUT << a.Qget () << "; cout << a.qu () <<"; cout << a.Qget () << "/ n ========== / N "; cout << B.Qget () <<" "; cout << B.Qget () <<"; cout << B.QGet () << "/ n";
COUT << A.Q [0] << '<< B.Q [0] << endl; return 0;