What is the best approach for a Java developer to learn C++ [closed]

冷暖自知 提交于 2019-12-17 21:45:24

问题


I consider myself an experienced Java developer and am planning to get started with learning C++.

If you had same experience, i.e learn C++ after Java, I would like to hear your thoughts on what is the best approach at doing this.

[Update] "the best approach" was not well quantified. What I am looking for is to leverage my existing java knowledge and programming experience so that I can quickly ramp up on C++.


回答1:


I've taught C++ to Java people, even though I learned them the other direction.

Are you comfortable with C? If not, read Kernighan and Ritchie. Many many peculiarities of C++ are explained by the desire for C++ to be a "Better C" with C's basic expression syntax.

You should get Stroustrup.

I think well of Thinking in C++ by Bruce Eckels.

I've used The C++ FAQ Book, by Cline, Lomow, and Girou; I refer to it pretty often. Marshall Cline has C++ FAQ content on his site, too.

Update

You might also look at C++ for Java Programmers. I don't know the book but it looks decent.




回答2:


My proposal would be to write highly pointer-based thing, like a linked list library, BST library, etc. The code should be STL-free, similar to pure C. You should build application using such library (eg. sort algorithms?) and learn how to deal with all the pitfalls which will for sure come up, if it's your first C/C++ code.

In my opinion the most important fundamental in knowing C++ is to understand pointers and low level memory representation of classes and structures. It's like an enlightenment after which everything is simple and clear ;)




回答3:


I would start with Effective C++ and More Effective C++ by Scott Meyers. These two books go over some really good best-practices for C++.

http://www.aristeia.com/books.html




回答4:


Others have already specified the required books. I would like to add just couple of points to be noted: ( as background is java)

  • C++ doesnot provide you the Garbage collection ( as in Java). Hence, you must be very perticular about memory leaks. Always use delete the memory allocated on heap using new. Try to remember the Free-Store management in FAQ while writing the C++ applications.
  • Most often in C++ you may have to work with pointers ( missing in Java). Learn pointers ( books suggested by @Charlie Martin) effectively and use them.
  • One you are familiar with C++, learn the basics of STL and use effectively. ( Book By Josuttis and Scott Meyers)

Good luck.




回答5:


I strongly disagree with learning C first, and with trying tgo learn C++ from the Effective books, excellent though they are. Instead, get hold of a copy of Accelerated C++ by Andrew Koenig and Barabra Moo - this is written by two of the original C++ development group and will teach you how to use modern C++ features.




回答6:


"C++ for Java Programmers" by Mark Allen Weiss is a good intro book for seasoned Java programmers.




回答7:


Andy and Charlie already gave you the books, so I will indicate the boost libraries and the Qt framework.

Boost gives you some basic functions to work with so you don't need to create everything from scratch.

Qt, as you may know, is a GUI framework, and I find it very enjoyable to use. There is a book called "C++ GUI Programming With Qt 4" that covers all the important topics to learn Qt.




回答8:


This is going to sound a little funny, but you asked for the best way, not the quickest. I'd suggest you start by learning C first, before you learn C++. Kernighan and Ritchie is one of the best language books ever written. When you know C and Java, you'll be able to write good, clear programs in a sensible subset of C++ with almost no additional effort.




回答9:


Learn Qt. Trust me on this; I'm both a Java and C++ developer; I can tell you Qt makes C++ language closer to Java. Don't just learn the bare-bone C++.

C++ with Qt makes you infinitely more productive. I used to combine so many different libraries (Boost, Intel's, database connectors, etc..) just to achieve the kind of stuff we do (high-performance/real-time computing). At the end, I found that more than 80% of what I need is already included in Qt.

Not to mention, imo, Qt has the best documentation on any framework/library I've worked on, which makes it very easy to just learn everything on your own.

Try it, and see for yourself.

Disclaimer: I'm just a developer--I dont work for Nokia. =p




回答10:


K&R and Stroustrup are classics, and eventually you should get them, but I don't think they are good introduction for C++ beginners. Thinking in modern C++ is thinking in classes, templates, exceptions, and streams, none of which available in C language.

I would recommend a college-level textbook on C++ like Deitel and Deitel.

After playing around, you should focus on learning to write a class that behaves like a built-in class. That means providing a copy constructor, operator=, operator==, operator<<, etc.. Along the way you'll meet various concepts embedded in the language of C++. I would agree with others on Effective C++ is a must read once you are comfortable with the basics.



来源:https://stackoverflow.com/questions/789659/what-is-the-best-approach-for-a-java-developer-to-learn-c

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