Skip to main content

Learning C++

  • Chapter
  • First Online:
Computing with Data
  • 3469 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Hardcover Book
USD 109.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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. 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. 3.

    The const_cast operator can be used to remove constness or volatility in many scenarios.

  4. 4.

    See Sect. 2.6.4 for more details on rounding, overflow, and underflow—all of which may occur in casting.

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

    Google Scholar 

  • S. B. Lippman, J. Lajoie, and B. Moo. C++ Primer. Addison-Wesley, fifth edition, 2012.

    Google Scholar 

  • N. M. Josuttis. The C++ Standard Library: A Tutorial and Reference. Addison-Wesley, second edition, 2012.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics