Does C++ have a Garbage Collector?(C++ 有垃圾收集器吗?)
问题描述
我目前正在阅读一份未发表的硕士论文报告,我将提供反馈.
I'm currently reading an unreleased master thesis report, that I'm going to give feedback on.
在报告中,他们提到了原生 C++ 和托管 C++ 下的 GC.我以为 C++ 没有任何标准的 GC,我是对还是错?(他们没有提到 Boehm-Demers-Weiser.)
In the report they mention GC under native C++ and managed C++. I thought C++ didn't have any standard GC, am I wrong or right? (They do not mention Boehm-Demers-Weiser.)
他们在某些条件下无法正常工作.它们在一个线程中创建对象,并从另一个线程中删除指针.
They have some problem getting it to work under some conditions. They create objects in one thread, and delete the pointer from another thread.
推荐答案
Native C++ 默认没有这样的东西(最接近这个的是智能指针,但这仍然是完全不同的东西),但这并不妨碍您无需编写自己的垃圾收集解决方案(或使用 第三方解决方案).
Native C++ by default has no such thing (the closest thing to this are the smart pointers, but that's still something entirely different), but that doesn't prevent you from writing your own garbage collection solution (or using third party solution).
托管 C++(及其后续 C++/CLI)当然对托管资源使用 .NET 垃圾回收(尽管本机资源不是垃圾回收,并且必须像在本机 C++ 中那样手动管理).
Managed C++ (and its successor C++/CLI) of course use .NET garbage collection for managed resources (though native resources are not garbage collected and have to be managed manually as in native C++).
这篇关于C++ 有垃圾收集器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++ 有垃圾收集器吗?
基础教程推荐
- CString 到 char* 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
