#include "stdafx.h"
#include <iostream>
using namespace std;
class Image
{
public:
Image()
{
cout << "construct !\n";
};
Image(const Image & inImg)
{
m_pBuf = inImg.m_pBuf;
m_nImgSize = inImg.m_nImgSize;
}
Image(const Image & inImg)
{
m_pBuf = inImg.m_pBuf;
m_nImgSize = inImg.m_nImgSize;
inImg.m_pBuf = NULL;
};
void allocBuff()
{
m_pBuf = new char[100];
}
~Image()
{
if (NULL != m_pBuf)
{
delete m_pBuf;
m_pBuf = NULL;
}
cout << "desconstruct !";
};
private:
char *m_pBuf;
int m_nImgSize;
};
int main()
{
Image * pImgA = new Image();
pImgA->allocBuff();
Image * pImgB = new Image(*pImgA);
if (NULL != pImgA)
{
delete pImgA;
pImgA = NULL;
}
return 0;
}