自增/自减运算符重载 — 计算机选择题
题目
设有如下定义:
struct Tick {
int n;
Tick(int x) : n(x) {}
Tick& operator++() { ++n; return *this; }
Tick operator++(int) { Tick old = *this; ++n; return old; }
int value() const { return n; }
};
执行 Tick t(6); int a=(t++).value(); int b=(++t).value(); 后,(a,b,t.value()) 的值是:
A. (6,7,7) B. (6,8,8) C. (7,8,8) D. (6,7,8)