1 2 3 4 |
Stack& Stack::operator>> (int &v) { v = pop(); return *this; } |
Định nghĩa lại toán tử →
1 2 3 4 |
Stack& Stack::operator>> (int &v)) { v = pop(); return *this; } |
Update lại hàm main để test →
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#include "mystack_04.h" #include <iostream> using namespace std; int main(void) { int i = 2, j; Stack stk; stk << 1 << 2 * i; stk >> j >> i; cout << j << endl << i << endl; return 0; } |