C++来自 Java 和 Objective-C

发布于 2024-11-19 11:53:04 字数 308 浏览 1 评论 0原文

所以,我对 Java 和 Objective-C 都很了解,但(也许很奇怪)从未真正学过 C++。显然,这些语言都是相关的,但存在我不完全理解的语法差异。是否有一个很好的文档描述了 C++ 的基础知识,但仍然假设学习者了解编程语言?甚至可能是旨在描述语言之间差异的教程。这就是我正在寻找的。

另外,是否有关于如何在 Mac 或 iOS 应用程序中使用 C++ 代码的好教程?我觉得需要学习 C++ 的原因是我正在尝试移植 C++ 程序,而且我听说您可以使用 C++ 代码并将其包装在 Obj-C GUI 中。有人可以向我指出一些有关如何执行此操作的文档/教程吗?

谢谢!

So, I know both Java and Objective-C quite well, but (perhaps strangely) never really learned C++. Obviously, the languages are all related, but there are syntactical differences that I don't fully understand. Is there a nice document that describes the basics of C++, but still assumes the learner knows a programming language? Perhaps even a tutorial that aims to describe the differences between the languages. This is what I'm looking for.

Also, is there a good tutorial on how to use C++ code inside a Mac or iOS app? The reason I feel the need to learn C++ is I'm trying to port a C++ program, and I heard you can use C++ code and just wrap it in an Obj-C GUI. Could someone point me to some documentation/tutorials on how to do this?

Thanks!

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

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

发布评论

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

评论(3

栖迟 2024-11-26 11:53:04

尽管这个家族的语言都是相关的,但这并不意味着您可以随意从一种语言转移到另一种语言并期望编写出漂亮的代码。你必须学习该语言的习语和特质,并体验其优势和思维方式。

我建议阅读斯特劳斯特鲁普的原著(当然是现代版)。这是最权威的参考(缺乏实际标准)并且写得非常清楚。这种方法的好处是,您将被教导思考“我将如何在 C++ 中做到这一点”,而不是“我如何音译这段 Java 代码以使其编译”。 (此外,这种方法消除了您可能认为应该“先学习 C” 的任何风险。不应该。)

在 MacOSX 上,要么下载并构建免费的 GCC,要么获取 XCode(随海湾合作委员会一起提供)。对于iOS我不知道,我怀疑你不能在上面部署本机代码。

Even though the languages of this family are all related, that does not mean that you can casually move from one to the other and expect to write beautiful code. You have to learn the language's idioms and idiosyncrasies, and experience its strengths and way of thinking.

I would recommend reading Stroustrup's original book (a modern edition, of course). It's the most definitive reference (short of the actual standard) and it is very clearly written. The benefit of this approach is that you will be taught to think "how would I do this in C++", rather than "how do I transliterate this piece of Java code to make it compile". (Also this approach does away with any risk you might have of thinking you should "learn C first". Don't.)

On MacOSX, either download and build the free GCC, or get XCode (which comes with GCC). For iOS I don't know, I have a suspicion that you cannot deploy native code on it.

兮子 2024-11-26 11:53:04

我会选择纯 C++ 路线,以材料的质量为指导,而不是寻找 ObjC+Java->C++ 材料。

在我工作的大学,出于显而易见的原因,我们尝试了两种方法向具有丰富编程经验(特别是 Java 经验)的学生教授 C++。

结论是,专业课程在教授 C++ 方面并不比带有一些额外练习材料的通用课程更好。重要的是教材的质量。

编辑:您可能会收到很多关于实际差异的好的答案,Voo 对您的问题的评论也是相关的。

I would go for a pure C++ route, the quality of the material being the guide rather than finding ObjC+Java->C++ material.

At the university I am working for we have tried both ways for teaching C++ to students with a lot of programming experience, in particular Java experience, for obvious reasons.

The conclusion was that the specialized course did no better in teaching C++ than the generic one with some extra exercise materials. It's the quality of the teaching materials that matters.

Edit: You will probably receive a lot of good answers on the actual differences, also Voo's comment on your question is relevant.

So要识趣 2024-11-26 11:53:04

我知道您的感受 - 已经研究过几种语言并学习 C++。我也有同样的经历。虽然我想了一段时间,我应该很容易就能学会它,但事实并非如此容易。然后我又回到基础知识并开始学习 C++。 《C++ Primer》是一本非常好的入门书。由于您了解大部分编程基础知识,因此可以浏览前几章的一些内容。完成此操作后,我会推荐“Effective C++”一书和此处维护的 C++ 常见问题解答 [http://www.parashift.com/c++-faq-lite/]。

事实上,您可以先浏览一下此常见问题解答,看看其中有多少意义,然后将其用作确定在何处进行深入研究的指南。

HTH,K

I know what you feel - to have already worked on a couple of languages and learning C++. I was in the same boat too. While I was thinking for a while that it should be easy for me to learn it right away, it wasn't all that easy. So then I went back to the basics and started as a fresher to learn C++. 'C++ Primer' is an extremely good book to start with. Since you know most of the basics of programming, some of the first few chapters can be skimmed through. Once you are through with this, I'd recommend 'Effective C++' book and the C++ FAQs maintained here [http://www.parashift.com/c++-faq-lite/].

In fact, you could go through this FAQ first and see how much of it makes sense, and use that as a guide for figuring out where to do a deep dive.

HTH, K

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