⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 f953.cpp

📁 c++程序c++程序c++程序c++程序
💻 CPP
字号:
# include <iostream>//为了达到对象整体复制的目的
using namespace std;
class Person{
	char *pName;
public:
	Person(char *pN="noName"){
		cout<<"Constructing "<<pN<<"\n";
		pName=new char[strlen(pN)+1];
		if(pName)strcpy(pName,pN);
	}
	Person(const Person & s){
		cout<<"copy Constructing "<<s.pName<<"\n";
		pName=new char[strlen(s.pName)+1];
		if(pName)strcpy(pName,s.pName);
	}
	~Person(){
		cout<<"Destructing "<<pName<<"\n";
		delete[] pName;
	}
};
	void main(){
		Person p1("Randy");
        Person p2(p1);
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -