The C++ programming language was created by Bjarne Stroustrup and his team at Bell Laboratories (AT&T, USA).C++ reads as C plus plus was derived from C programming language. ++ denotes the increment operator in C meaning increment of C is C++.
C++ greatly influenced development of C# and Java.
C progarm source code can be easily converted to C++ programs. C++ supports concepts for OOP (Object Oriented programming).
It is the ability to represent data at a very conceptual level without any details.
Data Encapsulation means protecting data form outside interfaces and controlling the access to data.
It means a class can be derived from base/parent class. The base class will have all the characteristics and feature of parent class.
Polymorphism is the ability to exist in various forms. It means representing same things differently.We will further discuss about above topics in detail in next tutorial.
In traditional concept of programming data and functions are kept separately. Due to which programmer must initialized suitable values before use.
fig: traditional concept
fig: OOP
Objects can be used as the building blocks of other program.
An object can change its properties: data member, functions without needing to change the application.
An object controls access to its data. So it can reject request of accessing it data outside the object.
After writing source code, it is then compiled by compiler which converts the high level language to machine code. Then linker combines the object file to form an executable file.
Any syntax error in program will be reported while compiling and more errors will be shown if further compiling takes place.
fig: working of C++ program
#include <iostream.h>
int main()
{
cout << "Hello World";
return (0);
}
To run the above program, We will be using Turbo C++. Download turbo C++ here.
Hello World
In above example,
#include <iostream.h>
Here, the line begins with # i.e the line is intended for processor. iostream.h is the header file. Above line import the iostream.h header file. iostream helps treating information as flow of data.
int main()
It indicates it is the main program. Once the program executes it will look for the main function. Execution of program starts here.
cout << "Hello World";
This outputs the text to Hello World on the screen. COUT means console output. << indicate that characters are being pushed to screen.
return 0;
It terminates the function and program while returning 0 indicating termination of program correctly.