使用C++不知道内存管理吗?

发布于 01-22 15:12 字数 1455 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白昼2025-01-29 15:12:24

在不知道内存管理的情况下使用C ++是危险的吗?

取决于您认为的“危险”以及您的学习和其他因素的愿意。

如果您试图在不了解语言的情况下编写程序,而又不尝试学习语言,那么结果可能是一个无法正常工作的程序,或者似乎有效的程序,但在看似无关的条件发生变化时会破坏。

在通常在C ++中开发程序时,是否有必要知道内存管理?

这取决于。

(可能令人惊讶的是)易于编写复杂的程序,同时避免任何手动记忆管理。但是,至少您仍然必须了解可能被认为是内存管理的基本部分的对象的寿命。

此外,如果要制定涉及内存管理的程序的任务,那么如果不了解内存管理,您将无法理解它。

如果我们不知道,我们会损坏计算机内存吗?

不,在大多数情况下不是。除非您正在编写控制一个可以触及并损坏自己电路的机器人臂的程序。

Is it dangerous to use C++ without knowing memory management?

Depends on what you consider "dangerous" and, how willing you are to learn and other factors.

If you attempt to write a program without understanding the language, and without attempting to learn it, then the outcome is likely a program that doesn't work, or one that appears to work but breaks when a seemingly unrelated condition changes.

Is it necessary to know memory management while developing programs in C++ normally?

It depends.

It's (possibly surprisingly) easy to write even complex programs while avoiding any manual memory management. However, at minimum you must still understand the lifetime of objects which may be considered a basic part of memory management.

Furthermore, if you were to be tasked with developing programs that do involve memory management, then you wouldn't be able to understand it without understanding memory management.

Can we damage computer memory if we don't know it?

No, not in most cases. Unless you are writing a program that controls a robot arm that can reach and damage its own circuits.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文