⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽

Creating a Class

Computer Programming C++ / Classes

Classes are the core building-block of object-oriented programming. They are user defined data-types (like structs) that contain data-members (fields) and member functions (methods).

Creating an object without any accessable members would be pretty pointless. The way that we allow access to our fields is through accessor and mutator methods.

We can add additional functionality to our classes through additional methods. These methods also have access to our member variables.

Objects as Data-Members

Sometimes you'll want to use objects inside of a class, which can create s few challenges. This video will demonstrate an implementation of an object member inside of a class.

Review Questions

The following are examples of questions similar to what you can expect to see on the next exam.

Hover over a question to show the answer.
  1. What is a class? Code that defines both fields (attributes) and methods (behaviors) for an object.
  2. What is another name for a member variable? A field.
  3. What is another name for a member function? A method.
  4. What does making a member of a class public do? Makes it accessable from outside of the class.
  5. What is another name for an accessor method? A "getter."
  6. What is another name for an mutator method? A "setter."

Above and Beyond

The content past here is related, but beyond the scope of the class. In other words, you will not be tested on this!

Const with Classes

The const keyword has additional uses when working with classes. It can be used, as you know, to create immutable variables. It can also be used to create constant parameters, and constant methods. This video will demonstrate.

⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽
© Ryan Appel