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++ 有垃圾收集器吗?


基础教程推荐
- 这个宏可以转换成函数吗? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01