C++ 有垃圾收集器吗?

Does C++ have a Garbage Collector?(C++ 有垃圾收集器吗?)

本文介绍了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++ 有垃圾收集器吗?

基础教程推荐