Chapter 3

Classes

Lesson Objectives

By the end of this chapter, you will be able to:

  • Declare and define a class
  • Access the members of a class using objects
  • Apply access modifiers to encapsulate data
  • Use the static modifier on data members and member functions
  • Implement a nested class
  • Utilize the friend specifier to access private and protected members
  • Use constructors, copy constructors, assignment operators, and destructors
  • Overload operators
  • Implement functors

In this chapter, we will be learning about classes and objects in C++.

Introduction

In the previous chapter, we saw how we can use functions to combine basic operations into units with a clear meaning. Additionally, in the first chapter, we saw how, in C++, we can store data ...

Get C++ Fundamentals now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.