标题:怎么调用析构函数??
取消只看楼主
caiqiufu
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2006-12-14
 问题点数:0 回复次数:0 
怎么调用析构函数??
#include<iostream.h>
class A
{
public:
A(int i=0)
{m=i;cout<<"Constructor called."<<m<<endl;}
void Print() const
{cout<<m<<endl;}
~A()
{cout<<"Destructor called."<<m<<endl;}
private:
int m;
};
void main()
{
const int N=5;
A my;
my=N;//该处为什么调用了一次析构函数??
my.Print();
}
搜索更多相关主题的帖子: 函数 int cout endl void 
2006-12-21 22:55



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-111187-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.102256 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved