Classes: Classes
Applies To: C++Builder 1 or higher
Category: C++ Language
- A class is a structure that contains variables and functions to modify this variables. Variables that are part of the class are called data members and the functions are named member functions. The general form of a class is:
-
class class_name {
protected:
public:
} objects;
|
|
-
- class_name is the name of the class. objects is an optional list of objects of type class_name.
-
- The protected, private and public keywords are used to control the access rights. Protected data members can be used only by the member functions of the class or classes derived from this class. Private items can't be read or changed by another class. Finally, public members can be accessed from anywhere. By default, all items in the class are private.
-
- For example:
-
- class Program {
-
- // Private data members
- int MainForm;
- char *Caption;
-
- // Public data members
- public:
- int ToolBar;
- char *Menu;
-
- };
C++Builder Developer's Network
Copyright © Yoto Yotov