复制构造函数
复制构造函数在那?
程序代码:#include "stdafx.h"
#include <iostream>
using namespace std;
class CStudent
{
private:
char *p_name;
int age;
public:
CStudent(char *,int);
~CStudent() {
if(p_name!=NULL)
delete p_name;
cout<<"destructor of class"<<endl;
}
void show(void);
};
CStudent::CStudent(char *source,int a)
{
p_name=new(char[strlen(source)+1]);
strcpy(p_name,source);
age=a;
}
void CStudent::show()
{
cout<<p_name<<" "<<age<<endl;
}
void main()
{
CStudent *p_student=new CStudent("张三",20);
CStudent stud1("李四",50);
CStudent stud3(stud1);
p_student->show();
stud1.show();
stud3.show();
delete p_student;
}
出现这个状况 那位帅哥帮忙解释下。








