为什么C ++使用指针? [英] Why does C++ use pointers?

查看:115
本文介绍了为什么C ++使用指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么C ++需要和使用指针?我知道他们增加了语言的力量,但他们让初学者很难理解。

Why does C++ need and use pointers? I know they add power to the language but they make it a lot harder to understand for beginners. Languages like F#, Java, Ruby, Python, Lua, etc. get by just fine without them, and they're quite powerful.

推荐答案

如果没有F#,Java,Ruby,Python,Lua等语言,

您提到的所有其他语言(和你忘了,至少,Java !!!),虽然每个非常有用和可用,不要让你在任何地方接近机器C ++(和C)允许:只是所有这些语言都会强加给你一个更高层次的抽象......这些都可能很好但偶尔会妨碍你。

All other languages you mention (and you forgot, at least, Java!!!), while each very useful and usable, don't let you get anywhere as close to the machine as C++ (and C) allow: simply put, all of those languages impose on you a higher level of abstraction... which may mostly be fine but will occasionally get in your way.

C ++是一个更大和更复杂的语言,因为它允许在真正低层次的抽象(非常接近机器)和在相当高的水平(接近您提到的许多语言)

C++ is a bigger and more complicated language because it allows programming at really low levels of abstraction (very close to the machine) AND at pretty high levels (close to many of the languages you mention) within the same language, indeed within the same source files.

初学者建议远离这个数量的权力和(不可避免的)并发症 - 而不是 >每个程序员是一个初学者,并不是每个位的代码需要(或者实际上,可以在所有 !)在一个环境中,让我们保护穷人shmucks自己作为主要设计目标!)

Beginners are well advised to stay FAR away from this amount of power and (inevitably) complication -- but not every programmer is a beginner, and not every bit of code needs (or, actually, can at all stand!-) being within an environment that has "let's protect the poor shmucks from themselves" as a major design goal!-)

这篇关于为什么C ++使用指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆