您的位置:首页 > 其它

构造与析构

2013-01-02 23:09 120 查看
//============================================================================

// Name : class_point.cpp

// Author :

// Version :

// Copyright : Your copyright notice

// Description : Hello World in C++, Ansi-style

//============================================================================

#include <iostream>

using namespace std;

class Point {

private :

double x,y,r;

public :

Point(double x,double y,double r);

~Point() {

x=y=r=0;

cout<<"ended sir";

}

double get_radius();

};

Point::Point(double x,double y,double r) {

this->x = x;

this->y = y;

this->r = r;

}

double Point::get_radius() {

return this->r;

}

int main() {

Point p(1,2,30);

cout<<p.get_radius();

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: