By Stephen R. Davis

C++ uses a structure known as the class. A class definition starts with the keyword class followed by the name of the class and an open brace. A class has the following format:

class Person
{
  public:
    char szFirstName[128];
    char szLastName[128];
    int  nSocialSecurityNumber;
};

The naming rules for class names are the same as for variable names: The first letter must be one of the letters ‘a’ through ‘z’ or ‘A’ through ‘Z’ or underscore. Every subsequent character in the name must be one of these or the digits ‘0’ through ‘9’. By convention, class names always start with an uppercase letter.

Class names normally consist of multiple words jammed together, with each word starting with an uppercase letter.

The first keyword within the open brace in the early examples will always be public.

You can also use the keyword struct instead of class. A struct is identical to a class in every respect except that the public is assumed in a struct. For historical reasons, the term class is more popular in C++; the term struct is used more often in C programs.

Following the public keyword are the declarations for the entries it takes to describe the class. The Person class contains two arrays for the first and last names and a third entry to hold the Social Security number.

The entries within a class are known as members or properties of the class.