Java 开发人员学习 C++ 的最佳方法是什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/789659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 19:31:27  来源:igfitidea点击:

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

javac++

提问by Journeyman Programmer

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

我认为自己是一名经验丰富的 Java 开发人员,并计划开始学习 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.

如果您有相同的经验,即在 Java 之后学习 C++,我想听听您对这样做的最佳方法是什么的想法。

[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++.

[更新]“最佳方法”没有很好地量化。我正在寻找的是利用我现有的 Java 知识和编程经验,以便我可以快速掌握 C++。

采纳答案by Charlie Martin

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

我已经向 Java 人教授了 C++,尽管我是从另一个方向向他们学习的。

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

你对 C 满意吗?如果没有,请阅读Kernighan 和 Ritchie。 C++ 的许多特性都可以通过希望 C++ 成为具有 C 基本表达式语法的“更好的 C”来解释。

You should get Stroustrup.

你应该得到Stroustrup

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

我认为Bruce Eckels的Thinking in C++很好。

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.

我使用了 Cline、Lomow 和 Girou 的The C++ FAQ Book;我经常提到它。Marshall Cline在他的网站上也有C++ FAQ 内容

Update

更新

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

您也可以查看C++ for Java Programmers。我不知道这本书,但看起来不错。

回答by Andy White

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++.

我将从 Scott Meyers 的 Effective C++ 和 More Effective C++ 开始。这两本书讨论了一些非常好的 C++ 最佳实践。

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

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

回答by besen

Andy and Charlie already gave you the books, so I will indicate the boostlibraries and the Qtframework.

Andy 和 Charlie 已经给了你书,所以我会指出boost库和Qt框架。

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

Boost 为您提供了一些基本功能,因此您无需从头开始创建所有内容。

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.

Qt,您可能知道,是一个 GUI 框架,我觉得使用起来非常愉快。有一本名为“C++ GUI Programming With Qt 4”的书涵盖了学习 Qt 的所有重要主题。

回答by besen

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.

我的建议是编写高度基于指针的东西,比如链表库、BST 库等。代码应该是无 STL 的,类似于纯 C。你应该使用这样的库构建应用程序(例如排序算法?)并学习如何处理所有肯定会出现的陷阱,如果这是你的第一个 C/C++ 代码。

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 ;)

在我看来,了解 C++ 最重要的基础是理解类和结构的指针和低级内存表示。这就像一个启蒙之后,一切都变得简单明了;)

回答by Norman Ramsey

This is going to sound a little funny, but you asked for the bestway, not the quickest. I'd suggest you start by learning C first, before you learn C++. Kernighan and Ritchieis 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.

这听起来有点好笑,但您要求的是最好的方式,而不是最快的方式。我建议您先学习 C,然后再学习 C++。 Kernighan and Ritchie是有史以来最好的语言书籍之一。当您了解 C 和 Java 时,您将能够使用 C++ 的合理子集编写好的、清晰的程序,几乎不需要额外的努力。

回答by aJ.

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

其他人已经指定了所需的书籍。我想补充几点需要注意的:(因为背景是java)

  • C++ doesnot provide you the Garbage collection ( as in Java). Hence, you must be very perticular about memory leaks. Always use deletethe memory allocated on heap using new. Try to remember the Free-Store managementin 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 Josuttisand Scott Meyers)
  • C++ 不为您提供垃圾收集(如在 Java 中)。因此,您必须非常注意内存泄漏。始终使用delete在堆上分配的内存使用new. 尝试在编写 C++ 应用程序时记住FAQ 中的免费商店管理
  • 大多数情况下,在 C++ 中,您可能必须使用指针(Java 中缺少)。有效地学习指针(@Charlie Martin 推荐的书籍)并使用它们。
  • 一个你熟悉C++,学习STL基础知识并有效使用的人。(JosuttisScott Meyers 着书

Good luck.

祝你好运。

回答by aJ.

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.

我强烈不同意先学习 C,然后尝试从 Effective 书籍中学习 C++,尽管它们很棒。相反,请获取Andrew Koenig 和 Barabra Moo 撰写的Accelerated C++副本- 这是由两个原始 C++ 开发小组编写的,将教您如何使用现代 C++ 功能。

回答by Eugene Yokota

K&Rand Stroustrupare 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.

K&RStroustrup是经典,最终你应该得到它们,但我不认为它们是 C++ 初学者的好入门。现代 C++ 中的思考是在类、模板、异常和流中思考,而 C 语言中没有这些。

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

我会推荐一本大学水平的 C++ 教科书,比如Deitel 和 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.

玩完之后,您应该专注于学习编写一个行为类似于内置类的类。这意味着提供复制构造函数、operator=operator==operator<<等。在此过程中,您将遇到嵌入在 C++ 语言中的各种概念。一旦你熟悉了基础知识,我会同意其他人关于Effective C++是必读的。

回答by Journeyman Programmer

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

Mark Allen Weiss 所著的“C++ for Java Programmers”是一本很好的入门书籍,适合经验丰富的 Java 程序员。

回答by sivabudh

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++.

学习Qt。相信我;我既是 Java 又是 C++ 开发人员;我可以告诉你 Qt 让 C++ 语言更接近 Java。不要只学习基本的 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.

带有 Qt 的 C++ 使您的工作效率无限提高。我过去常常结合很多不同的库(Boost、Intel 的、数据库连接器等)来实现我们所做的事情(高性能/实时计算)。最后,我发现我需要的 80% 以上已经包含在 Qt 中。

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

更何况,国际海事组织,Qt拥有任何框架/库我的工作,这使得它最好的文档容易,只是自己学习的一切。

Try it, and see for yourself.

试试看,自己看看。

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

免责声明:我只是一名开发人员——我不为诺基亚工作。=p