Lec 04-05
Lec 04-05
C++
Lecture – 4-5
• Getting started
– C and C++
– Basic program construction
– Data types
– Library functions
C++
• C++ is a statically typed, compiled, general purpose, case-sensitive
programming language that support procedural, object oriented &
generic purpose.
• C++ Development started in 1979.
• During the creation of Ph.D. thesis, Bjarne Stroustrup worked with
language called Simula.
• Simula was first language to support object-oriented programming
paradigm
• Bjarne Stroustrup identified that this OOP features can be
included in the software development.
• After that Bjarne Stroustrup started working on the C language
and added more extra OOP features to the classic C.
C++
• In this way, C++ was developed by Bjarne Stroustrup at Bell Labs in
Murray hills
Bjarne Stroustrup
C and C++
– C++ is advanced version of C language
– Every correct statement in C is also a correct statement in C++
– C++ contains all the features of C language and additionally
contains many other object oriented features like classes,
objects, inheritance and so on.
Functions
– A C++ program may consist of many functions, classes, and other
program elements.
screen.
– cout is predefined object that redirects the stream (flow of
data) to output device. cout is predefined in C++ library.
– The operator << is called the insertion or put-to operator. It
directs the contents of the variable on its right to the object on
its left.
Pre-processor Directives
#include <iostream>
#include <conio.h>
#include <iostream>
#include <conio.h>
• header/include file:
– iostream is an example of a header file.
– The pre-processor directive #include tells the compiler to add the
source file iostream to the source file before compiling.
– iostream is concerned with basic input/output operations and
contains declarations that are needed by the cout and <<
(insertion operator).
– Without iostream compiler won’t regonize cout and << and will
generate an error message.
– iostream file can be found in the include directory of C++
compiler
The using Directive
the using directive using namespace std;