this指针与静态成员 — 计算机选择题
题目
阅读代码,a.value() 在内层作用域结束后返回什么?
class Item {
int n;
static int alive;
public:
Item(int x) : n(x) { ++alive; }
~Item() { --alive; }
int value() const { return this->n + alive; }
};
int Item::alive = 0;
int main() {
Item a(6);
{ Item b(9); }
// 此处调用 a.value()
}
A. 6 B. 7 C. 8 D. 9