Abstract
C++ is a programming language that is especially well suited for computationally intensive programs and for interfacing with hardware or the operating system. In this chapter, we describe C++ starting with low-level features such as variable types, operators, pointers, arrays, I/O, and control flow, and concluding with object-oriented programming and the standard template library. We consider the latest version of C++ at the time of writing: C++17.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
We recommend to declare each variable on its own line to avoid declarations that can cause errors; for example, int* x, y; is not the same as int* y, x; as the * belongs to the variable name and not the type. See Chap. 15 for more style guidelines.
- 2.
The underscore character is allowed; some C++ compilers allow other special characters, but we recommend against using them to make the code more portable.
- 3.
The const_cast operator can be used to remove constness or volatility in many scenarios.
- 4.
See Sect. 2.6.4 for more details on rounding, overflow, and underflow—all of which may occur in casting.
- 5.
When calling by address, the parameter itself is not copied, but its memory address (pointer) gets copied and passed (by value) to the called function.
- 6.
A nonmember function or code in another class can access members of a friend class as if they were public. See Sect. 4.10.2 for more details on friendship in C++.
- 7.
It’s sufficient to declare a method in the base class as virtual for it to be virtual in all derived classes, but it’s good to repeat it explicitly to enhance readability.
- 8.
Occasionally more memory needs to be allocated when an object is appended to the end of a vector. However, these cases are rare and the insertion operation is considered fast in an amortized sense.
- 9.
In some cases, insertion and look-up may be very slow, but they are fast in an amortized sense.
References
B. Stroustrup. The C++ Programming Language. Addison-Wesley, fourth edition, 2013.
S. B. Lippman, J. Lajoie, and B. Moo. C++ Primer. Addison-Wesley, fifth edition, 2012.
N. M. Josuttis. The C++ Standard Library: A Tutorial and Reference. Addison-Wesley, second edition, 2012.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer Nature Switzerland AG
About this chapter
Cite this chapter
Lebanon, G., El-Geish, M. (2018). Learning C++. In: Computing with Data. Springer, Cham. https://doi.org/10.1007/978-3-319-98149-9_4
Download citation
DOI: https://doi.org/10.1007/978-3-319-98149-9_4
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-98148-2
Online ISBN: 978-3-319-98149-9
eBook Packages: Computer ScienceComputer Science (R0)