If you visit http://cosmostudio.tk/cpp, you will come across a plethora of information of the C++ programming language, direct from the designer of the language, Bjarne Stroustrup. Bjarne list a definition of C++ as:
“… a general-purpose programming language with a bias toward system programming that
· Is a better C
· Supports data abstraction
· Supports object-oriented programming
· Supports generic programming”
The language started in 1979 and was originally known as C with Classes. Essentially it meant that class files (used in object-oriented programming), were added to the C language. In 1983 it was renamed to C++.
C++ exits under the stewardship of standards committee and became an ISO standard in 1998 with a revision in 2011 and a minor revision in 2014. It continues to be updated as a part of the standards committee work.
C++ Program structure
A C++ Program has a very specific structure in terms of how the code is written and some key elements that you use in your C++ programs. The simplest of C++ programs is shown here
1. #include <iostream>
2.
3. Int main ()
4. {
5. Std: cout << “Hello World”;
6. Return 0;
7. }
In this simple hello world program, we notice some elements listed. The line numbers are used for reference only and are not part of the program code.
Meaning of per line shown below:
Line 1: this is known as a pre-processor directive. It instructs the compiler to locate the file that contains code for a library known as iostream. This library contains code that allows for input and output to streams, such as the console windows for program.
Line 3: - Every C++ program must have a method known as main (). And Also, C program should have this method. It is referred to as entry point for the application when you start execution of the program on your computer. The Int portion is the return type of the method. The empty parentheses () after the method name indicate that this a method and that it takes no arguments, in other word, there are no parameters for passing in Value.
Line 4: - It makes inform compiler that from here from gram is start. It also important in C and C++ Programing
Line 5: - it makes console or application what to do. Like in this example we have make message of hello world
Line 6: it means program is end press any key or exit console
Line 7: It tell compiler program is end. If we forget to insert this line program won’t debug.
C++ Statements
A C++ program is comprised of various components such as functions, methods, classes, etc. The instructions that from of a C++ program typically reside inside of functions or methods. These functions are comprised of C++ statements. You will find yourself using various types of statements in your C++ code as listed here:
· Declarations – these are used to declare variables and constants that will be used in your application code
· Assignments – these are used to assign values to variables in your application code
· Preprocessor directives – covered in the topic on Code Formatting – (Click here to See Code Formatting)
· Comments – sued to documents your code
· Function declarations – covered in the topic o code Formatting (Click here to See Code Formatting)
· Executable statements – these are used to perform operations and execute information instructions. Example would be cout<< “Hello World!”; which outputs Hello world! To the console.
You will use these statements types throughout this and successive courses on C++.
Click here to download this file on pdf
Download software to program C++ Language for free
Copyright © Newsun Banjade. 2018 All Right Reserved CPP

No comments:
Post a Comment