- C++ is an object-oriented programming language developed by Bjarne Stroustrup at AT & T Bell Laboratories in New Jersey, USA, in 1980.
- It is developed from Simula67 and C programming language.
- The new fundamental is class in C++ programming language other than C so it was given name ‘C with Classes’ for C++.
- But in 1983 from the increment operator (++) of C language the new name was given C++.
- In 1997 ANSI (American National Standard Institute) standardized C++.
- C++ is super-set of C and it is similar to C language.
- Most important facilities provided by C++ over C are: Class, Inheritance, function overloading and Operator overloading.
- C language uses top-down structure of programming while C++ uses bottom-up structure.
Comment:
- C++ provides new type of comment. It is single line comment.
- It starts with double slash (//) and end with the line.
- C++ also provides the multi-line comment provided in C in which we write comment in between ‘/*’ and ‘*/’.
- We can place multi-line comment in-between one statement while single line comment can’t.
- It is generally used to give description in one line only.
‘iostream’ header file:
- In C++ programs we have to include header file ‘iostream’ (Input Output STREAM file) as:
#include <iostream>
- But some old version of C++ compiler uses iostream.h, iostream.hpp, iostream.hxx, etc. file as the header file.
- This file mostly contains the classes and functions used for the input and output.
Input/Output Statement:
- In C program we use ‘printf’ and ‘scanf’ to print and read value respectively.
- These are the function while in C++ we use ‘cout’ and ‘cin’ class for printing and reading value respectively.
- These both class are written in file ‘iostream.h’.
- To print the output we use following statement:
cout << “C++ is superset of C language”;
- In above statement ‘cout’ is a class. ‘<<’ is an insertion or put to operator which is used to direct the output stream to ‘cout’. The output operation in C++ can be shown as under:
- We are passing C++ variable and string stream to the ‘cout’ class object by the insertion operator and ‘cout’ will send the stream to output device (i.e. screen)
- To read the value from the keyboard we use following statement:
cin >> a // Here ‘a’ is integer variable
- ‘cin’ is also class used for input. ‘>>’ is a get from or extraction operator which direct the input stream from ‘cin’ to the variable. The input operation can be shown as under:
- cin’ class object reads the value from keyboard and direct the value to the variable by extraction operator.