Object Oriented Programming
Object Oriented Programming
IN C++
Chapter 1
INTRODUCTION
TO C++
Introduction
What Is C++
Compatible extension of c
Support Object Oriented Programming
Support for Data Abstraction
Background
C++ designed by Bjarne Stroustrup (AT&T Bell
Labs)
Originally only meant as a pre-processor to
improve on some of the inadequacies of C
First commercial release 1985
Even today many consider C++ is not an object
oriented language but rather an object oriented
compiler-linker (subtle difference we'll learn
about later).
BPCL
C
Algol68
Simula67
(Smalltalk)
(Ada)
(LISP)
C++
Philosophy of C++
Keep the strengths and repair the
weaknesses
Efficiency is maintained
Compatability is maintained with C
Operate in all environments C can
Improved typing
Abstraction and Data encapulation vastly
improved
char
else
if
signed
union
const
enum
int
sizeof
unsigned
delete
friend
protected public
virtual
continue
extern
long
static
void
inline
template
flow control
I/O
functions and modularity
pointers
basic memory allocation
basic data structures
(arrays, lists, trees)
Input / Output
#include<iostream.h>
void main(void)
{
int a=1000;
cout << a is <<a<<endl;
cout <<enter number<<endl;
int b;
cin >>b;
a+=b;
cout << a is <<a<< and b is <<b<<endl;
}
Example of A Class
class Coord
{
public:
int x;
int y;
};
struct coord
{
int x;
int y;
};
Coord location;
location.x = 7;
location.y = 8;
cout << location.y;
location.x = 7;
location.y = 8;
printf(%d,location.y);