首页 > 编程语言 > 详细

c++旧教材--p81(构造函数和析构函数)

时间:2019-12-11 13:53:02      阅读:92      评论:0      收藏:0      [点我收藏+]

源程序:

#include <iostream>

using namespace std;

class Point

{

private:

  int x,y;

public:

  Point(int=0,int=0);

~Point(); 

};

Point::Point(int a,int b):x(a),y(b)

{

  cout<<"Initializing"<<a<<","<<b<<endl;

}

Point::~Point()   //定义析构函数

{

  cout<<"Destructor is active"<<endl;

}

void main()

{

  Point *ptr=new Point[2];

  delete []ptr;

}

c++旧教材--p81(构造函数和析构函数)

原文:https://www.cnblogs.com/duanqibo/p/12021953.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!