Welcome to this lecture. In this lecture we are going to take, an intro into the components of a C++ program structure:
Now that we have our environment set and working, we now need to break the program which you see on the screen into different component, so that we know and get to understand the components of a c++ program structure.
So let us begin.I hope you have your compiler open and running, or you prefer me to show you. So let us now try to understand each component of the program we are looking at on the picture below:
As we see, we first have the line written # include <iostream> in this piece of code, followed by a line written using namespace std; , then the third line written int main (), fourth line being a //Our First C++ Program which is a comment, you should note that every line of code that have two slashes is a comment. Second from last being cout << hello world << endl. last but not least a line written return zero. These are the components we are going to take a look at.
The Structure of a c++ program goes like this, first note that the program is divided into various sections, which I have showed you on the screen. These components are called headers, class definition, the member functions definition and the main Function.
Note that this simple program on the screen only contains, comments, headers, namespace, main, input and output statements. That being provided I have mentioned Class definition and member function definition, which are not in this simple program we have created.
The c++ language Is good enough to the point that it is flexible, to allow a user to write a code without classes and member functions involved, that being at this first stage.
So in the following lecture we are going to first take a look at the C++ Header files (headers).So stick around i will show you how,