- A typical C++ program would contain four section.
- They are Main function program, Member functions definitions, Class declaration and Include files.
- These sections may be placed in separate code files and then compiled independently or joined.

Structure of C++
INCLUDE FILES IN C++
- Header File is a file that allows programmers to separate certain elements of program’s source code into reusable files.
- Header file contains forward declaration of classes, variables and identifiers.
C++ DECLARATION
- A Declaration introduces one or more name into a program.
- Declaration can be occur more than once in a program.
- Therefore classes, structures, enumerated and user-defined types can be declared for each compilation unit.
- The constraint on this multiple declaration is that all declaration must be identical.
Example for C++ Declaration
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Declare and define int variables i and j. int i; int j = 10; // Declare enumeration suits. enum suits { Spades = 1, Clubs, Hearts, Diamonds }; // Declare class CheckBox. class CheckBox : public Control { public: Boolean IsChecked(); virtual int ChangeState() = 0; }; |
MEMBER FUNCTIONS IN C++ PROGRAM
- Classes can contain data and function. These functions are referred to as “member functions”.
- Any non-static function declared inside a class declaration is considered as a member function.
- It is a common practice to organize a program into separate files.
- The class declarations are placed in a header file and the definitions of member functions go into another file.
- This approach enables the programmer to separate the abstract specification of the interface (class definition) from the implementation details (member functions definition).
- The main program that uses the class is placed in a third file which “includes” the previous two files as well as any other files required .

Client-Server Model
- This approach is based on the concept of client-server model.
- The class definition including the member functions constitute the server that provides service to the main program known as client.
- The client uses the server through the public interface of the class.





