Structure of C++ Program

Structure of C++ Program
A typical C++ program would contain four sections as shown in figure This section may be placed in separate code files and then compiled independently or jointly.
It is a common practice to organize a program into three 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 from the implementation details (member function definition).

Finally, the main program that uses the class is places in a third file which “includes: the previous two files as well as any other file required.


figure: structure of c++ program


This approach is based on the concept of client-server model as shown in figure below. The class definition including the member functions constitute the server that provides services to the main program known as client. The client uses the server through the public interface of the class.



figure: client-server model


Comments

Popular posts from this blog

Application of OOP

Simple C++ Program

Benefits of OOP (object oriented programming)