先上代码
#include "stdafx.h"
#include <string>
using namespace std;
class CStudent
{
public:
CStudent(char *pName) :m_pName(NULL)
{
if (NULL == pName)
{
return;
}
m_pName = new char[strlen(pName) + 1];
strcpy(m_pName, pName);
printf("CStudent: address:0x%08x name:%s\n", this, m_pName);
}
~CStudent()
{
printf("~CStudent: address:0x%08x name:%s\n", this, m_pName);
delete m_pName;
}
//拷贝构造函数
CStudent(const CStudent &a) :m_pName(NULL)
{
if (NULL