Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7192379
  • 博文数量: 510
  • 博客积分: 12019
  • 博客等级: 上将
  • 技术积分: 6836
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-01 16:46
文章分类

全部博文(510)

文章存档

2022年(2)

2021年(6)

2020年(59)

2019年(4)

2018年(10)

2017年(5)

2016年(2)

2015年(4)

2014年(4)

2013年(16)

2012年(47)

2011年(65)

2010年(46)

2009年(34)

2008年(52)

2007年(52)

2006年(80)

2005年(22)

分类: C/C++

2010-06-13 11:37:00

#include
using namespace std;

class ABC{
private:
int m_i;
void * m_p;
public:
    ABC(){};
    ABC(void*p):m_p(p){cout<<"构造ABC2="<};


class Test
{
public:
Test();
~Test();
Test(const Test& t);
Test& operator=(const Test& t);
private:
int t1;
public:
ABC m_abc;
};

Test::Test():m_abc(this)
{
cout<<"调用构造函数"<}

Test::~Test()
{
cout<<"调用析构函数"<}

Test::Test(const Test& t)
{
cout<<"调用复制构造函数"<}

Test& Test::operator =(const Test& t)
{
cout<<"调用赋值构造函数"<t1 = t.t1;
return *this;
}

int main()
{
Test t1;
Test t2 = t1;
//Test t3;
//t3 = t1;
    return 0;
}

阅读(1979) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~