In our last post we have introduced you to the object oriented programming.Today we shall know about the structure of c++ program.The structure of c++ program mainly divided into three parts.
2.Declaration of classes
Let us go in detail about all these sections.Starting with Header file section.
1.Headers Files: As we know that all the commands in any compiler are divided into two types. They are User defined and pre-defined words. For user defined words user should specify compiler about the meaning of the command.Pre-defined words are defined in the library files of the compiler.Therefore we need to include header files which defines the word.For any c++ program we should include iostream.h header file at the beginning of the program. There are some many header files and they are included depending upon the usage of the keywords in the program.
2.Declaration of classes: We know that class is the main feature of the object oriented programming.In c++ program we need to declare all classes before main function.Though many classes are needed in the program we need to declare all these classes before main function.A class may contain data members and member-functions,therefore we need to define these member functions before the main function.
3.Main function: Main function of program is like heart of our body. Though a program may contain 100 functions compiler checks for main function in the program. All our program will be executed depending upon the order of commands specified in the main functions. Following is a sample program to explain you structure of c++ program.
#include iostream.h //Header file part//
class A //Class declarations//
cout<<"Let us learn Programming":
void main() //Main function//