computer 版 (精华区)
发信人: remember (Learning C++), 信区: program
标 题: 什么时候会产生临时对象(第一个问题)
发信站: 听涛站 (2001年10月25日20:49:51 星期四), 站内信件
看看下面一段代码,你认为会产生临时对象么?
换言之,你认为程序输出结果是多少?
class A {
public:
A() { count++; }
A(int i) { count++; }
~A() {}
int getcount() { return count; }
private:
static int count;
};
int A::count=0;
int main() {
A a;
int n=5;
A=n;
cout<<"count is:"<<a.getcount()<<endl;
return 1;
}
--
洛阳亲友如相问 一片冰心在玉壶
※ 来源:·听涛站 tingtao.dhs.org·[FROM: 匿名天使的家]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.913毫秒