终止内务管理是什么意思
what does termination housekeeping mean?
"终止内务管理"一词是什么意思?我读过析构函数用于对类的对象执行终止内务处理。我不知道这是什么意思。
谢谢。
在析构函数的上下文中,终止内务处理是在销毁对象之前要完成的工作。
如果要在系统回收对象的存储之前执行某些操作,请在析构函数中编写代码。
例如,初学者使用它来理解被调用的构造函数和析构函数的顺序。
让我们从这里举一个例子:
#include <iostream>
using namespace std;
class Line {
public:
void setLength( double len );
double getLength( void );
Line(); // This is the constructor declaration
~Line(); // This is the destructor: declaration
private:
double length;
};
// Member functions definitions including constructor
Line::Line(void) {
cout << "Object is being created" << endl;
}
Line::~Line(void) {
// THE PLACE FOR TERMINATION HOUSEKEEPING
cout << "Object is being deleted" << endl;
}
void Line::setLength( double len ) {
length = len;
}
double Line::getLength( void ) {
return length;
}
// Main function for the program
int main( ) {
Line line;
// set line length
line.setLength(6.0);
cout << "Length of line : " << line.getLength() <<endl;
return 0;
}
你可以在这里看到另一个例子。
相关文章:
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 标准 N3337 5.2.10 第 7 条中的C++"类型"是什么意思?
- "类模板示例<int>;"语句对 C++11 是什么意思?
- 线应该是什么意思
- "CID"在AT+HTTPPARA= "CID" ,1中是什么意思
- 表达式"b=(b-x)&x"是什么意思?
- 这个表达是什么意思?
- 此代码验证公式是什么意思?
- 跟踪日志中的T.11803()是什么意思?
- 这个额外的关键字在这个 c++ 类声明中是什么意思?
- * 和 ** 在 C++ 函数声明中是什么意思?
- _T("xyz")是什么意思?
- #define Dbg(fmt,..) (0) 是什么意思? 警告:表达式无效
- 这行代码到底是什么意思?
- 在命名空间名称之前加上 :: 是什么意思?
- 从字符数组的元素中减去'a'是什么意思
- "friend"关键字在C++中是什么意思?
- 减法中的"0"是什么意思?
- 字符数组前面的加号是什么意思?
- 这里的字符串函数是什么意思