OOPortal 





C++ Class Construct  «Prev  Next»
Lesson 1

Introduction to C++ Class Construct

This module explores some of the basic concepts of building classes in C++ and introduces you to the internal workings of the class construct.



 class CRectangle {
    int x, y;
  public:
    void setValues (int,int);
    int area (void);
  } rect;

Declares a class called CRectangle and an object of this class called rect.
This class contains four members:
  1. two data members of type int (member x and member y) with private access (because private is the default access level) and
  2. two member functions with public access: setValues() and area(),
of which for now we have only included their declaration, not their definition.