New to C++, help me get started(C++ 新手,帮助我开始)
问题描述
我是一名 Java 程序员,有一点 C 知识,想开始使用 C++,有人可以推荐一个好的教程吗?
Im a Java programmer, with a little C knowledge who wants to get started with with C++ can someone recommend a good tutorial?
还有任何帮助:
- 学习项目
- 推荐阅读
- 什么 IDE ?我目前使用 NetBeans
- 一般 C++ 建议
推荐答案
取决于你的目标平台,我使用 Visual Studio 作为 IDE.
Depends on your target platform, I use Visual Studio as an IDE.
与 Java 相比,C++ 的一般规则是它包含比 Java 更多的自由,特别是在模板与泛型、堆栈与堆以及对象的执行(或缺乏)方面方向和它的原则.例如,C++ 提供了打破封装的友元语句 const_cast,在堆栈上分配对象并且指针可以指向它们,模板比泛型拥有无限的权力等等.
The general rule of C++ as opposed to Java is that it contains a hell of a lot more freedom than Java, especially as regards to templates vs generics, the stack vs the heap, and the enforcement (or lack thereof) of object orientation and it's principles. For example, C++ provides the encapsulation-breaking friend statement, the const_cast, allocates objects on the stack and pointers can point to them, templates have infinitely more power than generics, etc.
您必须习惯的另一件主要事情是资源管理.C++ 不提供 GC.您需要熟悉 RAII(资源获取即初始化)以及基于范围的构造和销毁如何工作以避免资源泄漏.
The other main thing you will have to get used to is resource management. C++ does not provide a GC. You will need to familiarize yourself with RAII (resource acquisition is initialization) and how scope-based construction and destruction work to avoid resource leaks.
您还需要复习标准模板库 (STL).STL 比 Java 库有更直接的方法——例如,std::iostream 类提供了从文件中提取浮点数、字符串等的本地方法,而在 Java 中,您需要 File 和 Scanner,尽管它是范围更有限 - 没有 GUI 或基于目录的组件,仅适用于初学者.
You will also need to brush up on the Standard Template Library (STL). The STL has a much more directed approach than the Java libraries- for example, the std::iostream class provides native methods to extract floats, strings, etc from the file, whereas in Java you need both a File and a Scanner, although it's scope is far more limited- no GUI or directory-based components, just for starters.
哦,顺便说一句,说真的,放弃你的 C 知识.它会伤害而不是帮助你.
Oh, by the way, seriously, ditch your C knowledge. It'll hurt rather than help you.
这篇关于C++ 新手,帮助我开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++ 新手,帮助我开始
基础教程推荐
- 设计字符串本地化的最佳方法 2022-01-01
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 运算符重载的基本规则和习语是什么? 2022-10-31
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- C++,'if' 表达式中的变量声明 2021-01-01