Unit1 OOP.ppt
Unit1 OOP.ppt
Unit1 OOP.ppt
C is a programming language
which is developed by Dennis Ritchie in 1972 at AT & T’s
bells laboratories located in USA. It is developed to use in
UNIX operating system.
While C was a Procedural
Oriented Programming language (POP) i.e. more
significance was given to the procedure to perform a task.
Introduction to C++ language
C++ is a programming
language which is developed by Bjarne Stroupstrup
in 1979 at bells laboratories located in USA.
It is Object
Oriented Programming language (OOP). Earlier C+
+ is known as C with classes.
Difference Between C and C++
C C++
1) C is develop by Dennis Ritchie in 1972. 1) C++ is develop by Bjarne Stroupstrups
in 1979.
2) In C overloading is not possible. 2) In C++ overloading is possible.
OOP POP
1) Program is divided into small parts it is 1) Program is divided into small parts it is
called as function. called as object.
2) It does not have any proper way 2) It provide data hiding so it is
to hide the data so it is less secure. more secure.
3) POP does not have any access 3) OOP have access specifier.
specifier.
4) Example :- C , Pascal. 4) Example :- C++,Java.
Structure of C++ program
• Structure of C++ program :-
# include<iostream.h>
# include<conio.h>
int main()
{
//Statements
return 0;
getch();
}
Tokens
• Tokens :-
A token is defined as the smallest individual unit
present in the program.
• Types of tokens :-
1) Keywords.
2) Identifiers.
3) Constants.
4) Variables :- Variables are the name associated with some values.
5) Operators : - Operators are the special symbols.
1) Keywords
• Keywords :-
Keywords are the reserved words . They
have their specific meaning . Keywords use in c++ are as
follows:-
int, float ,char ,void , return , if ,else, switch, case, double , for ,
struct ,class, break etc.
2) Identifiers
• Identifiers are the name given to different user define things.
• Like :- Variables, Constant, functions, classes, object, structure,
union etc.
Rules of identifier :-
1)It is consist of alphabets, digits and special symbol i.e. (‘_’).
2)It start only with alphabet or special symbol i.e. (‘_’).
3)Blank space are not used.
4)It is case sensitive.
3) Constants
• Constant :-
Constant are the fixed values which does not change.
• Example :-
# define abc 83 here, # define is the compiler directive
who tell’s the compiler whenever abc is found in the program replace it by its
value i.e. 83.
Types of operator
• There are four types of operator as follows :
1)Arithmetic operator :- +, -, *, /, %.
2)Logical operator :- &&,||.
3)Relational operator :- ==, <=, >=, !=, <, >.
4)Bitwise operator :- &, ^, |, ~, <<, >>.
Decision making statement
• It is also called as control structure.
• Decision making statement decides the direction of flow
of program.
• Types of decision making statement are as follows:-
1. If statement
2. If else statement
3. Nested if statement
4. If - else - if ladder
1) If statement
• Syntax :-
If (condition)
{
// Statement 1;
-------------------
// Statement n;
}
2) If else statement
• Syntax :-
If (condition)
{
// Statement 1;
-------------------
// Statement n;
}
else
{
// Statement 1;
-------------------
// Statement n;
}
3) Nested if statement
Syntax :- If (condition)
{
If (condition)
{
// Statement ;
}
}
4) If - else - if ladder
• Syntax :-
If (condition) {
// Statements;
}
else If (condition) {
// Statements;
}
else If (condition) {
// Statements;
}
else {
// Statements;
Loops
• loops are used to repeat a block of code.
• Types of loops :-
1) For loop
2) While loop
3) Do while loop
1) For loop
• Syntax :-
for (initialization; condition; update)
{
// Statement;
}
2) While loop
• Syntax :-
while (condition)
{
// Statements;
}
3) Do while loop
• Syntax :-
do
{
// Statements;
} while (condition);
Scope resolution operator
(::)
• Scope resolution operator :-
We can access the
variables or functions which is in the class by this operator, from
anywhere in the program.
• Syntax :-
Return_type class_name:: function_name()
{
}
Array
• Array :- Array is a collection of similar datatype.
Ex:- we can have a array of integer type, float type or character type etc.
• Syntax :-
Data_type array_name [array_size];
• Example:-
int a[5];
• Types of array :-
1) One dimensional:-
2) Multi dimensional:-
Strings
• String :-
String is a collection of
characters. It is a contiguous block of memory.
Syntax:- string var_name[size];
Ex:- string a[20];
Structure
• Structure :-
Structure is a collection of different data
types.
Syntax:-
struct structure_name
{
data_type variable_name;
data_type variable_name;
…..
…..
}object1, object2, objectn;