C++ 中类的析构函数
来源:互联网 发布:java 启动参数 编辑:程序博客网 时间:2024/05/23 11:48
#include <iostream>
#include <cmath>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
using namespace std;
class Line
{
public:
void setLength( double len );
double getLength( void );
~Line();
private:
double length;
};
Line::~Line(void)
{
cout << "Object is being deleted" << endl;
}
void Line::setLength( double len )
{
length = len;
}
double Line::getLength( void )
{
return length;
}
int main( )
{
Line line;
line.setLength(6.0);
cout << "Length of line : " << line.getLength() <<endl;
return 0;
}
#include <cmath>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
using namespace std;
class Line
{
public:
void setLength( double len );
double getLength( void );
~Line();
private:
double length;
};
Line::~Line(void)
{
cout << "Object is being deleted" << endl;
}
void Line::setLength( double len )
{
length = len;
}
double Line::getLength( void )
{
return length;
}
int main( )
{
Line line;
line.setLength(6.0);
cout << "Length of line : " << line.getLength() <<endl;
return 0;
}
阅读全文
0 0
- 【C/C++】实现一个string类的构造函数、析构函数和赋值函数
- [c++]派生类的构造函数和析构函数
- C++:类的构造函数和析构函数
- c++---派生类的构造函数和析构函数
- Effective c++(笔记) 中关于构造函数、析构函数以及赋值操作符的知识
- C中不安全的函数
- c中不安全的函数
- c中不安全的函数
- c中不安全的函数
- C中不安全的函数
- c中不安全的函数
- C中常用的函数
- C中函数的声明
- 【C/C++】函数中指针的传递
- 高质量C++/C编程指南---类的构造函数,析构函数,赋值
- 【C++】类构造函数 & 析构函数
- C++——类的构造函数、析构函数与赋值函数用法浅谈
- C/C++学习笔记:String类的构造函数、析构函数和赋值函数
- 【国际】美国监管机构:加密货币会为信用社带来风险的同时提供机遇
- 无穷小微积分落地生根在中国的可能性分析
- Codeforces Round #382 (Div. 2)C. Tennis Championship(贪心) D.巴赫猜想
- 二分查找(递归和非递归两种方法)
- Python3.5基础——变量、数据结构、条件和循环语句、break与continue语句
- C++ 中类的析构函数
- Java注解的实现与使用
- 51nod 1163 贪心+优先队列
- C++多态及虚函数的理解和使用
- 深度学习资料整理
- java 编程规范 数据类型 运算符 分支判断if switch等初识
- MySQL访问权限系统
- 基于html5 Canvas图表库 : ECharts
- C++解析字符串,调用函数