C++ coming from Java and Objective-C

我们两清 提交于 2019-12-22 04:50:44

问题


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!


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/6643550/c-coming-from-java-and-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!