This lab discusses:

  1. What is a class
  2. Class definitions
  3. Access control
  4. Constructor
  5. Member function definitions
  6. How to instantiate an object of a class
  7. How to call member functions

Class Definition

class Class_name
  constructor declaration
  member function declarations
  data members

Member Function Definitions

output Class_name::memberfunName(input parameters)
  body of the function

Example: Point.cpp (Point class)


Write a Rectangle class using the Point class and test it using a main program (i.e., in a main() function).

A rectangle is specified by two corner points. The sides of the rectangle are parallel to the coordinate axes.

Consider the following design description of the Rectangle class:

Can do:

BU CAS CS - Introduction to Classes
This page created by Jisook Youn <>.
Material partially taken from the textbook "Computing Concepts with C++ Essentials", by Horstmann.