C++ Program Structure

Structure of C++ Program : Layout of C++ Program

C++ Programming language is most popular language after C Programming language. C++ is first Object oriented programming language.We have summarize structure of C++ Program in the following Picture –

Structure of C++ Program

Structure of C++ Program

Section 1 : Header File Declaration Section

  1. Header files used in the program are listed here.
  2. Header File provides Prototype declaration for different library functions.
  3. We can also include user define header file.
  4. Basically all preprocessor directives are written in this section.

Section 2 : Global Declaration Section

  1. Global Variables are declared here.
  2. Global Declaration may include –
    • Declaring Structure
    • Declaring Class
    • Declaring Variable

Section 3 : Class Declaration Section

  1. Actually this section can be considered as sub section for the global declaration section.
  2. Class declaration and all methods of that class are defined here.

Section 4 : Main Function

  1. Each and every C++ program always starts with main function.
  2. This is entry point for all the function. Each and every method is called indirectly through main.
  3. We can create class objects in the main.
  4. Operating system call this function automatically.

Section 5 : Method Definition Section

  1. This is optional section . Generally this method was used in C Programming.