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

📄 f0912.cpp

📁 《C++程序设计教程(第二版)》源代码 源代码中包括运行所需的数据文件,它的格式是*.txt,还有*.in和*.out的。头文件格式是*.h
💻 CPP
字号:
//=====================================
// f0912.cpp
// constructing object from other object
//=====================================
#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(){
    cout <<"Destructing "<<pName<<"\n";
    delete[] pName;
  }
};//-----------------------------------
int main(){
  Person p1("Randy");
  Person p2(p1);
}//====================================

 

⌨️ 快捷键说明

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