SlideShare a Scribd company logo
1 of 121
CENTRE FOR INFORMATION
TECHNOOLGY,UPES ,DEHRADUN
• Name of the staff

: VENKATADRI.M.

• Designation

:Asst Prof (SS).

• Branch

: Computer Science and Engineering.

• Institute

: University Of Petroleum and Energy
Studies

• Semester

: III

• Subject

: OOPS With C++

• Subject Code

:.

• Topic

: Understand the concept of OOP
methodology

•Teaching aids used

: Diagrams, animations, PPT
Objective
On completion of this period, you would be
able to know
• Evolution of OOPS( Object Oriented
Programming )
• History of C++

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun

2
RECAP
• Do you know about C language ?

• It is based on what program design ?
• Is it Procedure / Object oriented ?

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Appreciate the evolution of OOP
• OOPs was evolved to overcome the drawbacks
of conventional programming methods.
• It allows dividing a problem into no.of entities
called as Objects.
• OOP treats data as a critical element in the
program.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun

4
Appreciate the evolution of OOP

• It does not allow the data to flow freely around the
system.
• It hides the data.
• It provides security to the data.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun

5
Organization of data & functions in
OOPS
Object A

Object B

Data
Functions
Communication

Data
communication

Functions

Object C

Communication

Data
Functions

Fig 1.1

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun

6
History of C++
•

C++ was developed by Bjarne Stroustrup at
Bell Labs in USA.

• It was initially called as “C with Classes”.
• It is super set of ‘C’ language.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun

7
History of C++
•It follows bottom-up program design.
• Objects will communicate with each other.
• Objects are independent.
• It binds the data and functions together.
Venkatadri.M,Asst Prof
(SS).UPES,Dehradun

8
Summary
In this class , you have learnt …
• Evolution of OOPS

• History of C++

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun

9
Frequently Asked Questions

1. Explain the Evolution of OOPS.
2. Explain the History of C++.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun

10
Quiz
1. OOPS was developed by________________.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Quiz
1. OOPS was developed by Bjarne Stroustrup

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Quiz
2. C++ is __________________ Programming
language.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Quiz
2. C++ is Object Oriented Programming
language.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Quiz
3.

C++ is based on___________________.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Quiz
3.

C++ is based on Objects.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Quiz
4. C++ provides _________________to the data.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Quiz
4.

C++ provides Security to the data.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Quiz
5. OOPS is _______________ programming
design.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Quiz
5.

OOPS is Bottom up programming design.

Venkatadri.M,Asst Prof
(SS).UPES,Dehradun
Procedure Oriented Programming (POP)

CM505.2

21
Limitations of POP
• Emphasis is on algorithm or procedure

• Not suitable for modeling a real world problem
• No security & integrity to the data
• Data can’t be hidden
• Inheritance & Polymorphism are difficult to achieve
CM505.2
22
Limitations of POP
• Follows top down program design
• Can’t reuse the existing code
• Data will be shared by many functions
• Difficult to write and understand
CM505.2

23
Organization of data & functions in
OOPS
Object A

Object B

Data
Functions
Communication

Data
communication

Object C

Functions
Communication

Data
Functions

Fig 2.2

CM505.1

24
Features of Object Oriented Languages
• Emphasis is on data rather than the procedure

• Both data and functions are combined into a
single unit
• Data can’t be accesssed directly

CM505.2

25
Features of Object Oriented Languages
• Data is hidden and can’t be accessed by external
functions
• Programs are divided into elements known as
objects
• Objects may communicate with each other
through functions
CM505.2

26
Features of Object Oriented Languages
• New data and functions can be easily added

• Follows bottom up approach of program design
• We can eliminate the redundant code
• Time will be saved

CM505.2

27
Features of Object Oriented Language
• Higher productivity
• Provides multiple instances of an object
• Provides security to the data
• Easy to write and understand a program
CM505.2

28
Features of Object Oriented Languages
• Data is critical element.

• Data can not be freely accessed by extenal functions
• Permits reusability of the existing code

CM505.2

29
Languages that support OOPs

• C++
• Small talk
• Java
• Simula etc

CM505.2

30
Features of Object Oriented Language
• We can easily upgrade from small to large systems
• We can build user defined data types
• Objects are to classes as variables are to data types

CM505.2

31
Applications of OOPS
• Artificial Intelligence & Expert systems

• Simulation & modeling
• OO databases
• Hypertext, Hyper media and Expertext
• CAD / CAM / CAE
CM505.2

32
Applications of OOPS
•Decision support system
• Neural Networks
• Real time systems
• Multimedia applications
• GUI, CBTs, Office automation etc
CM505.2

33
Properties of oops
•
•
•
•
•
•

Object
Class
Encapsulation
Data abstraction
Inheritence
Polymorphism

CM505.3

34
Objects
• Objects are the basic run time entities.

• Can be defined as an identifiable entity
with characteristics and behavior.
• We are often surrounded by variety of
objects like
• computer
• chair
• telephone etc.,
CM505.3

35
Characteristics of Object

• State
• Behavior
• Identity

CM505.3

36
Characteristics of Object
Example:Consider the object telephone it has
• a set of attributes like color, shape, and model
etc.,
• Behaviour is that it announces a call.
• Identity is the unique telephone number.
CM505.3

37
Object communication
• Objects interact with each other by sending
messages to each other.
• It occupies space in memory.
• Each object is having its own address.

CM505.3

38
Object communication
• Each object contains data and some code to
manipulate the data.
• for example
Object: Student
DATA:
Name
Marks
FUNCTIONS:
Total
Average

CM505.3

39
Object communication
• Objects have life cycle.

• They can be created and destroyed.
• Communication with an object is feasible as long
as it is alive.

CM505.3

40
Classes
• It is defined as a collection of objects of similar type.

• The set of data and code of an object can be made a
user defined data type using a class.
• In fact objects are variables of type class.
• We can create any number of objects belonging to
that defined class.
CM505.3

41
Classes
Example:banana, apple and mango are the examples of
members of class of fruit.
• If fruit is defined as class then
Fruit mango;
Will create an object mango belonging to the
class fruit.
CM505.3

42
Encapsulation
• The wrapping up of data and functions into single

unit is known as ‘ENCAPSULATION’.
• The data is not accessible to outside world.
• Only the member functions within the class can
access the data.
CM505.3

43
Encapsulation
•These functions provide an interface between the
object’s data and the program.
• This insulation of data from direct access by the
program is called data hiding.

CM505.3

44
Data Abstraction
• Abstraction refers to the representation of essential

features without including background details or
explanations.
• Since the classes use data abstraction they are
also known as Abstract Data Type (ADT).

CM505.3

45
Inheritance
• It is the process of creating a new class from
the existing class.
• The new class inherits all the characteristics of
the existing class.
• It is like a hierarchical classification.

CM505.3

46
Inheritance
• We can add additional features to an existing
class without modifying it. This is known as
reusability.
• Each derived class shares common
characteristics with the class from which it is
derived.
• The new class will have combined features of
both the classes.
CM505.3

47
Inheritance

CM505.3

48
Polymorphism
• The ability to take more than one form.
• An operation may exhibit different behaviours in
different instances.
• The behaviour depends upon the types of data
used in the operation.
• Polymorphism is used extensively in
implementing the inheritance.
CM505.3

49
Polymorphism-Example

CM505.3

50
Polymorphism-operator over loading
•Consider the operation of addition.
• For two numbers it generates a sum.
• If the operands are string then the operation
would produce a third string by concatenation.

CM505.3

51
Polymorphism-operator over loading
•The process of making an operator to exhibit
different behaviours in different instances is
known as operator overloading.
• A single function name can be use to handle
different members and different types of
arguments.
CM505.3

52
Polymorphism – function overloading
• It is nothing but a particular word in having several

different meanings depending on the context.
• Using a single function name to perform different
types of tasks is known as function overloading.

CM505.3

53
Dynamic binding

• It is also known as late binding.

• The code associated with a given procedure is
not known until the time of call at run time.

CM505.3

54
Objective
The end of the class you would be able to
learn…
• Creating a C++ program
• Compiling & linking it
• Running

CM505.4

55
RECAP
• What is a program?

• How to create a program in C ?
• What is a compiler ?

CM505.4

56
Program development & execution

Fig 4.1
CM505.4

57
Creating a C++ program
• Turbo C++ provides a powerful environment called

IDE for creating and executing a C++ program.
• The IDE is completely menu-driven and allows the
user to create, edit, compile and run programs using
dialogue boxes.

CM505.4

58
Creating a C++ program
• We first use the editor to create the C++ source
code file.
• When we invoke TURBO C++, we get the IDE
screen.
• It contains 4 parts as shown in fig B.2 in the next
slide

CM505.4

59
TURBO C++ - IDE

CM505.4

60
TURBO C++ - IDE
• Now we can create and save a program in C++

• The F10 key will take you to main menu
• Now select the File option
• We have options like new, open, save etc
• Select the new option from file menu
• We get a blank window called as editing window
CM505.4

61
TURBO C++ - IDE
• Now the system is ready to receive the program

statements
• After typing the program save the program in a file
• We can also save a program by pressing F2 key
• File name should have the extension .CPP
Ex :• test.cpp is the name of the C++ file
CM505.4

62
Compiling a C++ program
• We can compile a program by choosing the

compile option on the main menu
• We get a compile dialogue window
• Select the option compile
• We get test.obj file after the compilation
•
CM505.4

63
Compiling a C++ program
• During compilation we get a compilation window
• If there are no errors this window will display a
message as “ Success: Press any key” as shown
in the fig 4.3 in the next slide
• We can also compile a program by pressing F9
key
CM505.4

64
TURBO C++ - Compilation screen

CM505.4

65
Linking

• To link the object file test.obj with the standard

library functions, select the link option from the
compile menu
• We get a third file test.exe after linking

CM505.4

66
Running the program
• To run a program select the Run option from the
main menu
• We can also run a program by pressing (Ctrl + F9)
key
• We get the output on the screen
CM505.4

67
Objective

On completion of this period, you would be able to
know
• Structure of C++ program.

CM505.6

68
Recap
In the previous class, we have discussed about
Difference between c & c++

CM505.6

69
Structure of C++
• The C++ program contains four sections as shown
in figure 6.1.
• These sections may be placed in separate code
files and then compiled independently or jointly .

CM505.6

70
Structure of C++ program :
Include files
Class declaration

Class functions
Definitions
main function
program

Fig 6.1
CM505.6

71
Structure of C++ program
• We can organize a program into three separate
files.
• The class declarations are placed in a header
file.
• The definitions of member functions go into
another file.
• The main program that uses the class is placed
in third file which includes the previous two files
CM505.6

72
Structure of C++
• This approach enables the programmer to
separate the abstract specification of the
interface( class definition) from the
implementation details (member functions
definitions).

CM505.6

73
Structure of C++
• This approach is based on the concept of client
–server model as shown in fig.
Member functions
Server

Class definition

Main function program
Client

Fig 6.2: Client-server model.
CM505.6

74
Structure of C++
• The class definition including the member functions
constitute the server.
• The server that provides services to the main
program known as the client.
• The client uses the server through the public
interface of the class.

CM505.6

75
•

An example program with class.

#include<iostream.h> //Include files
class person
{
char name[30];
int age ;
public:
void get data(void);
void display(void);
};
void person::getdata(void)
{
cout<<“Enter name:”;
cin>>name;
cout<<“Enter age:”;
cin>>age;
CM505.6
}

// class declaration

.
//class function definition

76

[contd….]
• An example program with class.
void person::display(void)
{
cout<<“n name:”<<name;
function definition
cout<<“age:”<<age;
}
main()

// class

{
person p;
p.getdata();
function program
p.display();
}

// main
CM505.6

77
Objective
On completion of this period, you would be able to
learn….
• Input operators
• Output operators
• Examples

CM505.7

78
INTRODUCTION

CM505.7

79
Cin & Cout
• C++ input/output resolves around the motion of a
data stream.
• We can insert data into an output stream or
extract data from an input stream.
• The standard output stream to the screen is
referred to as “cout”.
• The standard input stream from the keyboard is
referred to as cin.
• We can also cascade the I/O operators
CM505.7

80
Cin – Input from the Keyboard:
•
•
•
•

cin stands for console in
It is used to accept input data from keyboard.
It can read only one word at a time
It is also known as extraction / get from operator
syntax :- cin>>variable name;
Ex:- cin>>x1>>x2;
We obtain input from the keyboard through the
stream cin ,using the extraction operator >> .
CM505.7

81
Example
To read two integer values from the keyboard
into integer variables num1 and num2, we can
write as follows:
Cin>>num1>>num2;

CM505.7

82
Example :
Contd..
Object
Cin

Keyboard

Extraction Operator

>>

Variable
45.5

Fig 7.1 :- Input using extraction operator
CM505.7

83
Description :
• “>>” this operator is known as extraction
operator.

• The operation will be in the direction of the
data flow.
• The input statement executes from left to right.
• It extracts the value from the keyboard and
assigns it to the variable on its right.
• We can overload this operator
CM505.7

84
Description (contd..):
• Floating point values are read from the
keyboard in exactly the same way as integers.
• We can also mix the two.
• The stream input and operations automatically
deal with variables and any data type.

CM505.7

85
Description (contd..):
For exmple, look at the statements:
int num1=0,num2=0;
double factor=0.0;
cin>>num1>>factor>>num2;
The last line will read an integer into num1,
then a floating point value into factor and finally
an integer into num2.
CM505.7

86
Cout – Output to the display :
• Cout is a predefined object that represents the
standard output stream in C++.
• The standard output stream is screen
• It is also possible to redirect the o/p to other
o/p devices
• It is reverse of cin .
• The operator “<<“ is also called as insertion /
put to operator
CM505.7

87
Screen

Cout

Object

<<
Insertion Operator

“C++”

Variable

Fig 7.2 :- Output using insertion operator
CM505.7

88
Description :
syn:- cout<<variable name;
Ex:- cout<<x1<<x2;
If x1= 1234 & x2= 5678 ,then output
will be “12345678”.

CM505.7

89
Description (contd..):
• The object cout has a simple interface.
• It inserts the contents of the variable on its right
to the object on its left.
• If name represents a string variable, then the
following statement will display its contents:
cout << name;
CM505.7

90
Description (contd..):
• We can also use this operator for overloading
• This concept is known as Operator
Overloading, an important aspect of
polymorphism.
• We can also use printf() statement in C++

CM505.7

91
Manipulator
• These are the operators that are used to format
the data display.
• These are defined in the header file iomanip.h
• The most commonly used manipulators are
setw & endl

CM505.7

92
Set width or setw(n)
Definition :
It is an io manipulator which will
output the value right justified in a ‘n’ spaces
wide.
syn:- setw(n);
Ex:- cout<<setw(6)<<x1<<setw(7)<<x2;

CM505.7

93
Escape sequence
Definition :
These are the execution character set
& starts with a ‘’ character set.
For ex:- cout <<endl<<“Hello”;
cout<<endl<<“t Hello”;
Output :

Hello
Hello

CM505.7

94
OBJECTIVES

On completion of this period, you would be able to
learn…
• Comment statements in C
• Comment statement in C++
• Keywords of C++ other than C

CM505.8

95
RECAP
• What is meant by comment ?
• What is keyword ?
• List keywords in C ?

CM505.8

96
Comments in C++
• A comment is used for the documentation purpose.
• Comment starts with a double slash symbol(//) and
terminates at the end of the line.
• It may start any where in the line.
• There is no closing for a comment.
•

Comments are not executable.

• All comments are ignored by the compiler.

CM505.8

97
Comments in C++
There are two ways of writing a comment.
• Single line comment.
Eg:- // write a program to add two numbers.

• Multi line comment.
Eg:- /* write a program
• to add two
• numbers */

CM505.8

98
Comment statements in C
• C programmers are familiar with the /*..*/
style of commenting.
• Anything lying within the /*..*/ pair is ignored
by the compiler.
•

Eg:-/*This is the program*/

CM505.8

99
Comment statements in C++

For example:
//This is an example
//of C++ program
/* This is an example of C program */

CM505.8

100
Comment statements in C
NOTE:
•

You should always comment your
programs comprehensively.

•

The comment should be sufficient for any
programmer.

CM505.8

101
Keyword
• Keyword or Reserved word is an identifier.

• It is pre-defined to the compiler.
• Keyword can’t be used for naming a variable in
programming.

CM505.8

102
Keywords of C++ other than C
•
•
•
•
•
•
•
•

•
•
•
•
•
•
•
•

class
delete
friend
public
catch
new
template
operator
CM505.8

try
throw
private
protected
inline
asm
this
virtual

103
Keywords of C++ other than C
• class:
It is an improvement over structure of c
conceptually, class is a way to bind data and its
associated functions together.

• delete:
Delete object pointed by a pointer must be used
on an object created by new operator.

CM505.8

104
Keywords of C++ other than C
• friend:
A friend function declared as friend has access
to object of the class . It is not to member of any
class.

• public:
It is an access specifier.Members declared
public can be accessed freely in the program.
CM505.8

105
Keywords of C++ other than C
• catch:
It catches and processes the exception.

• new:
It is an operator used for allocating memory
dynamically.

CM505.8

106
Keywords of C++ other than C
• operator:
used in operator function to overload an
existing operator.

• template:
Constructs a family of related functions or
classes.They are sometimes called parameterized
classes.

CM505.8

107
Keywords of C++ other than C
• try:
A block prefaced with keyword try can be throw an
exception.

• throw:
A mechanism for handling exceptions.

CM505.8

108
Keywords of C++ other than C
• private:
It is an access specifier.Members declared private
can be accessed freely in the program.

• protected:
It is an access specifier.Members declared
protected can be accessed freely in the program.
However, such members can be directly inherited
directly in a derived class.

CM505.8

109
Keywords of C++ other than C
• inline:
In C++ you can declare and define a member
function within its class such function is called inline.

 asm:
You use Asm statements to use assembly
language statements in the middle of your C++
source code.

CM505.8

110
Keywords of C++ other than C
• this:
It is a pointer.When any object is
created, the system on its own sets a pointer
to that object.the name of the pointer variable
is ‘this’.
• virtual:
It can be used to make a class or
function virtual.
CM505.8

111
Summary
• Comment statements in C
• Comment statements in C++
• Keywords of C++ other than C

CM505.8

112
Any Questions….

CM505.8

113
Frequently used Questions
1.

Define a comment?

2.

Explain the comment statements in C++?

3.

List the keywords of C++ other than C?

CM505.8

114
Quiz
1. Comment start with a __________symbol.

CM505.8

115
Quiz
1. Comment start with a Double slash symbol.

CM505.8

116
Quiz
2. Catch is a keyword of________.

CM505.8

117
Quiz
2. Catch is a keyword of C++.

CM505.8

118
Quiz
3. There are ________ways of commenting in C+
+.

CM505.8

119
Quiz
3. There are Two ways of commenting in C++.

CM505.8

120
Thank you

CM505.2

121

More Related Content

What's hot

Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesFellowBuddy.com
 
Introduction to object oriented language
Introduction to object oriented languageIntroduction to object oriented language
Introduction to object oriented languagefarhan amjad
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS abhishek kumar
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming languageMd.Al-imran Roton
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaMadishetty Prathibha
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programmingSachin Sharma
 
Constructor and desturctor
Constructor and desturctorConstructor and desturctor
Constructor and desturctorSomnath Kulkarni
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languagesppd1961
 
Introduction to oop using java
Introduction  to oop using java Introduction  to oop using java
Introduction to oop using java omeed
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
Encapsulation in C++
Encapsulation in C++Encapsulation in C++
Encapsulation in C++Hitesh Kumar
 

What's hot (20)

Oops ppt
Oops pptOops ppt
Oops ppt
 
Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture Notes
 
Basic concepts of oops
Basic concepts of oopsBasic concepts of oops
Basic concepts of oops
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Introduction to object oriented language
Introduction to object oriented languageIntroduction to object oriented language
Introduction to object oriented language
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
 
Constructor and desturctor
Constructor and desturctorConstructor and desturctor
Constructor and desturctor
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
 
Introduction to oop using java
Introduction  to oop using java Introduction  to oop using java
Introduction to oop using java
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
encapsulation
encapsulationencapsulation
encapsulation
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Oop
OopOop
Oop
 
concept of oops
concept of oopsconcept of oops
concept of oops
 
Encapsulation in C++
Encapsulation in C++Encapsulation in C++
Encapsulation in C++
 
Java
JavaJava
Java
 
Characteristics of oop
Characteristics of oopCharacteristics of oop
Characteristics of oop
 

Similar to Introduction to oop

Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)MD Sulaiman
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTnikshaikh786
 
Software Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-iSoftware Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-iTaymoor Nazmy
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programmingAmar Jukuntla
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfHouseMusica
 
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.pptsagarjsicg
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)Jay Patel
 
Kelis king - introduction to software design
Kelis king -  introduction to software designKelis king -  introduction to software design
Kelis king - introduction to software designKelisKing
 
Object Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperObject Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperLee Greffin
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP conceptsAhmed Farag
 
gxhrehsrejhvytftfltyflytdtydtydky5dyrdtrdrdtrd
gxhrehsrejhvytftfltyflytdtydtydky5dyrdtrdrdtrdgxhrehsrejhvytftfltyflytdtydtydky5dyrdtrdrdtrd
gxhrehsrejhvytftfltyflytdtydtydky5dyrdtrdrdtrdwrushabhsirsat
 

Similar to Introduction to oop (20)

Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)
 
80410172053.pdf
80410172053.pdf80410172053.pdf
80410172053.pdf
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPT
 
c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
c++ Unit I.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Software Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-iSoftware Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-i
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
 
OOP-1.pptx
OOP-1.pptxOOP-1.pptx
OOP-1.pptx
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdf
 
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 
Kelis king - introduction to software design
Kelis king -  introduction to software designKelis king -  introduction to software design
Kelis king - introduction to software design
 
Object Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperObject Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft Developer
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
gxhrehsrejhvytftfltyflytdtydtydky5dyrdtrdrdtrd
gxhrehsrejhvytftfltyflytdtydtydky5dyrdtrdrdtrdgxhrehsrejhvytftfltyflytdtydtydky5dyrdtrdrdtrd
gxhrehsrejhvytftfltyflytdtydtydky5dyrdtrdrdtrd
 
The Big Picture
The Big PictureThe Big Picture
The Big Picture
 

More from Kumar

Graphics devices
Graphics devicesGraphics devices
Graphics devicesKumar
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithmsKumar
 
region-filling
region-fillingregion-filling
region-fillingKumar
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivationKumar
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons dericationKumar
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xsltKumar
 
Extracting data from xml
Extracting data from xmlExtracting data from xml
Extracting data from xmlKumar
 
Xml basics
Xml basicsXml basics
Xml basicsKumar
 
XML Schema
XML SchemaXML Schema
XML SchemaKumar
 
Publishing xml
Publishing xmlPublishing xml
Publishing xmlKumar
 
Applying xml
Applying xmlApplying xml
Applying xmlKumar
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XMLKumar
 
How to deploy a j2ee application
How to deploy a j2ee applicationHow to deploy a j2ee application
How to deploy a j2ee applicationKumar
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLKumar
 
EJB Fundmentals
EJB FundmentalsEJB Fundmentals
EJB FundmentalsKumar
 
JSP and struts programming
JSP and struts programmingJSP and struts programming
JSP and struts programmingKumar
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programmingKumar
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversKumar
 
Introduction to J2EE
Introduction to J2EEIntroduction to J2EE
Introduction to J2EEKumar
 

More from Kumar (20)

Graphics devices
Graphics devicesGraphics devices
Graphics devices
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithms
 
region-filling
region-fillingregion-filling
region-filling
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
 
Extracting data from xml
Extracting data from xmlExtracting data from xml
Extracting data from xml
 
Xml basics
Xml basicsXml basics
Xml basics
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Publishing xml
Publishing xmlPublishing xml
Publishing xml
 
DTD
DTDDTD
DTD
 
Applying xml
Applying xmlApplying xml
Applying xml
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
How to deploy a j2ee application
How to deploy a j2ee applicationHow to deploy a j2ee application
How to deploy a j2ee application
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XML
 
EJB Fundmentals
EJB FundmentalsEJB Fundmentals
EJB Fundmentals
 
JSP and struts programming
JSP and struts programmingJSP and struts programming
JSP and struts programming
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programming
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC Drivers
 
Introduction to J2EE
Introduction to J2EEIntroduction to J2EE
Introduction to J2EE
 

Recently uploaded

Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

Recently uploaded (20)

Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Introduction to oop

  • 1. CENTRE FOR INFORMATION TECHNOOLGY,UPES ,DEHRADUN • Name of the staff : VENKATADRI.M. • Designation :Asst Prof (SS). • Branch : Computer Science and Engineering. • Institute : University Of Petroleum and Energy Studies • Semester : III • Subject : OOPS With C++ • Subject Code :. • Topic : Understand the concept of OOP methodology •Teaching aids used : Diagrams, animations, PPT
  • 2. Objective On completion of this period, you would be able to know • Evolution of OOPS( Object Oriented Programming ) • History of C++ Venkatadri.M,Asst Prof (SS).UPES,Dehradun 2
  • 3. RECAP • Do you know about C language ? • It is based on what program design ? • Is it Procedure / Object oriented ? Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 4. Appreciate the evolution of OOP • OOPs was evolved to overcome the drawbacks of conventional programming methods. • It allows dividing a problem into no.of entities called as Objects. • OOP treats data as a critical element in the program. Venkatadri.M,Asst Prof (SS).UPES,Dehradun 4
  • 5. Appreciate the evolution of OOP • It does not allow the data to flow freely around the system. • It hides the data. • It provides security to the data. Venkatadri.M,Asst Prof (SS).UPES,Dehradun 5
  • 6. Organization of data & functions in OOPS Object A Object B Data Functions Communication Data communication Functions Object C Communication Data Functions Fig 1.1 Venkatadri.M,Asst Prof (SS).UPES,Dehradun 6
  • 7. History of C++ • C++ was developed by Bjarne Stroustrup at Bell Labs in USA. • It was initially called as “C with Classes”. • It is super set of ‘C’ language. Venkatadri.M,Asst Prof (SS).UPES,Dehradun 7
  • 8. History of C++ •It follows bottom-up program design. • Objects will communicate with each other. • Objects are independent. • It binds the data and functions together. Venkatadri.M,Asst Prof (SS).UPES,Dehradun 8
  • 9. Summary In this class , you have learnt … • Evolution of OOPS • History of C++ Venkatadri.M,Asst Prof (SS).UPES,Dehradun 9
  • 10. Frequently Asked Questions 1. Explain the Evolution of OOPS. 2. Explain the History of C++. Venkatadri.M,Asst Prof (SS).UPES,Dehradun 10
  • 11. Quiz 1. OOPS was developed by________________. Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 12. Quiz 1. OOPS was developed by Bjarne Stroustrup Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 13. Quiz 2. C++ is __________________ Programming language. Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 14. Quiz 2. C++ is Object Oriented Programming language. Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 15. Quiz 3. C++ is based on___________________. Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 16. Quiz 3. C++ is based on Objects. Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 17. Quiz 4. C++ provides _________________to the data. Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 18. Quiz 4. C++ provides Security to the data. Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 19. Quiz 5. OOPS is _______________ programming design. Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 20. Quiz 5. OOPS is Bottom up programming design. Venkatadri.M,Asst Prof (SS).UPES,Dehradun
  • 21. Procedure Oriented Programming (POP) CM505.2 21
  • 22. Limitations of POP • Emphasis is on algorithm or procedure • Not suitable for modeling a real world problem • No security & integrity to the data • Data can’t be hidden • Inheritance & Polymorphism are difficult to achieve CM505.2 22
  • 23. Limitations of POP • Follows top down program design • Can’t reuse the existing code • Data will be shared by many functions • Difficult to write and understand CM505.2 23
  • 24. Organization of data & functions in OOPS Object A Object B Data Functions Communication Data communication Object C Functions Communication Data Functions Fig 2.2 CM505.1 24
  • 25. Features of Object Oriented Languages • Emphasis is on data rather than the procedure • Both data and functions are combined into a single unit • Data can’t be accesssed directly CM505.2 25
  • 26. Features of Object Oriented Languages • Data is hidden and can’t be accessed by external functions • Programs are divided into elements known as objects • Objects may communicate with each other through functions CM505.2 26
  • 27. Features of Object Oriented Languages • New data and functions can be easily added • Follows bottom up approach of program design • We can eliminate the redundant code • Time will be saved CM505.2 27
  • 28. Features of Object Oriented Language • Higher productivity • Provides multiple instances of an object • Provides security to the data • Easy to write and understand a program CM505.2 28
  • 29. Features of Object Oriented Languages • Data is critical element. • Data can not be freely accessed by extenal functions • Permits reusability of the existing code CM505.2 29
  • 30. Languages that support OOPs • C++ • Small talk • Java • Simula etc CM505.2 30
  • 31. Features of Object Oriented Language • We can easily upgrade from small to large systems • We can build user defined data types • Objects are to classes as variables are to data types CM505.2 31
  • 32. Applications of OOPS • Artificial Intelligence & Expert systems • Simulation & modeling • OO databases • Hypertext, Hyper media and Expertext • CAD / CAM / CAE CM505.2 32
  • 33. Applications of OOPS •Decision support system • Neural Networks • Real time systems • Multimedia applications • GUI, CBTs, Office automation etc CM505.2 33
  • 34. Properties of oops • • • • • • Object Class Encapsulation Data abstraction Inheritence Polymorphism CM505.3 34
  • 35. Objects • Objects are the basic run time entities. • Can be defined as an identifiable entity with characteristics and behavior. • We are often surrounded by variety of objects like • computer • chair • telephone etc., CM505.3 35
  • 36. Characteristics of Object • State • Behavior • Identity CM505.3 36
  • 37. Characteristics of Object Example:Consider the object telephone it has • a set of attributes like color, shape, and model etc., • Behaviour is that it announces a call. • Identity is the unique telephone number. CM505.3 37
  • 38. Object communication • Objects interact with each other by sending messages to each other. • It occupies space in memory. • Each object is having its own address. CM505.3 38
  • 39. Object communication • Each object contains data and some code to manipulate the data. • for example Object: Student DATA: Name Marks FUNCTIONS: Total Average CM505.3 39
  • 40. Object communication • Objects have life cycle. • They can be created and destroyed. • Communication with an object is feasible as long as it is alive. CM505.3 40
  • 41. Classes • It is defined as a collection of objects of similar type. • The set of data and code of an object can be made a user defined data type using a class. • In fact objects are variables of type class. • We can create any number of objects belonging to that defined class. CM505.3 41
  • 42. Classes Example:banana, apple and mango are the examples of members of class of fruit. • If fruit is defined as class then Fruit mango; Will create an object mango belonging to the class fruit. CM505.3 42
  • 43. Encapsulation • The wrapping up of data and functions into single unit is known as ‘ENCAPSULATION’. • The data is not accessible to outside world. • Only the member functions within the class can access the data. CM505.3 43
  • 44. Encapsulation •These functions provide an interface between the object’s data and the program. • This insulation of data from direct access by the program is called data hiding. CM505.3 44
  • 45. Data Abstraction • Abstraction refers to the representation of essential features without including background details or explanations. • Since the classes use data abstraction they are also known as Abstract Data Type (ADT). CM505.3 45
  • 46. Inheritance • It is the process of creating a new class from the existing class. • The new class inherits all the characteristics of the existing class. • It is like a hierarchical classification. CM505.3 46
  • 47. Inheritance • We can add additional features to an existing class without modifying it. This is known as reusability. • Each derived class shares common characteristics with the class from which it is derived. • The new class will have combined features of both the classes. CM505.3 47
  • 49. Polymorphism • The ability to take more than one form. • An operation may exhibit different behaviours in different instances. • The behaviour depends upon the types of data used in the operation. • Polymorphism is used extensively in implementing the inheritance. CM505.3 49
  • 51. Polymorphism-operator over loading •Consider the operation of addition. • For two numbers it generates a sum. • If the operands are string then the operation would produce a third string by concatenation. CM505.3 51
  • 52. Polymorphism-operator over loading •The process of making an operator to exhibit different behaviours in different instances is known as operator overloading. • A single function name can be use to handle different members and different types of arguments. CM505.3 52
  • 53. Polymorphism – function overloading • It is nothing but a particular word in having several different meanings depending on the context. • Using a single function name to perform different types of tasks is known as function overloading. CM505.3 53
  • 54. Dynamic binding • It is also known as late binding. • The code associated with a given procedure is not known until the time of call at run time. CM505.3 54
  • 55. Objective The end of the class you would be able to learn… • Creating a C++ program • Compiling & linking it • Running CM505.4 55
  • 56. RECAP • What is a program? • How to create a program in C ? • What is a compiler ? CM505.4 56
  • 57. Program development & execution Fig 4.1 CM505.4 57
  • 58. Creating a C++ program • Turbo C++ provides a powerful environment called IDE for creating and executing a C++ program. • The IDE is completely menu-driven and allows the user to create, edit, compile and run programs using dialogue boxes. CM505.4 58
  • 59. Creating a C++ program • We first use the editor to create the C++ source code file. • When we invoke TURBO C++, we get the IDE screen. • It contains 4 parts as shown in fig B.2 in the next slide CM505.4 59
  • 60. TURBO C++ - IDE CM505.4 60
  • 61. TURBO C++ - IDE • Now we can create and save a program in C++ • The F10 key will take you to main menu • Now select the File option • We have options like new, open, save etc • Select the new option from file menu • We get a blank window called as editing window CM505.4 61
  • 62. TURBO C++ - IDE • Now the system is ready to receive the program statements • After typing the program save the program in a file • We can also save a program by pressing F2 key • File name should have the extension .CPP Ex :• test.cpp is the name of the C++ file CM505.4 62
  • 63. Compiling a C++ program • We can compile a program by choosing the compile option on the main menu • We get a compile dialogue window • Select the option compile • We get test.obj file after the compilation • CM505.4 63
  • 64. Compiling a C++ program • During compilation we get a compilation window • If there are no errors this window will display a message as “ Success: Press any key” as shown in the fig 4.3 in the next slide • We can also compile a program by pressing F9 key CM505.4 64
  • 65. TURBO C++ - Compilation screen CM505.4 65
  • 66. Linking • To link the object file test.obj with the standard library functions, select the link option from the compile menu • We get a third file test.exe after linking CM505.4 66
  • 67. Running the program • To run a program select the Run option from the main menu • We can also run a program by pressing (Ctrl + F9) key • We get the output on the screen CM505.4 67
  • 68. Objective On completion of this period, you would be able to know • Structure of C++ program. CM505.6 68
  • 69. Recap In the previous class, we have discussed about Difference between c & c++ CM505.6 69
  • 70. Structure of C++ • The C++ program contains four sections as shown in figure 6.1. • These sections may be placed in separate code files and then compiled independently or jointly . CM505.6 70
  • 71. Structure of C++ program : Include files Class declaration Class functions Definitions main function program Fig 6.1 CM505.6 71
  • 72. Structure of C++ program • We can organize a program into three separate files. • The class declarations are placed in a header file. • The definitions of member functions go into another file. • The main program that uses the class is placed in third file which includes the previous two files CM505.6 72
  • 73. Structure of C++ • This approach enables the programmer to separate the abstract specification of the interface( class definition) from the implementation details (member functions definitions). CM505.6 73
  • 74. Structure of C++ • This approach is based on the concept of client –server model as shown in fig. Member functions Server Class definition Main function program Client Fig 6.2: Client-server model. CM505.6 74
  • 75. Structure of C++ • The class definition including the member functions constitute the server. • The server that provides services to the main program known as the client. • The client uses the server through the public interface of the class. CM505.6 75
  • 76. • An example program with class. #include<iostream.h> //Include files class person { char name[30]; int age ; public: void get data(void); void display(void); }; void person::getdata(void) { cout<<“Enter name:”; cin>>name; cout<<“Enter age:”; cin>>age; CM505.6 } // class declaration . //class function definition 76 [contd….]
  • 77. • An example program with class. void person::display(void) { cout<<“n name:”<<name; function definition cout<<“age:”<<age; } main() // class { person p; p.getdata(); function program p.display(); } // main CM505.6 77
  • 78. Objective On completion of this period, you would be able to learn…. • Input operators • Output operators • Examples CM505.7 78
  • 80. Cin & Cout • C++ input/output resolves around the motion of a data stream. • We can insert data into an output stream or extract data from an input stream. • The standard output stream to the screen is referred to as “cout”. • The standard input stream from the keyboard is referred to as cin. • We can also cascade the I/O operators CM505.7 80
  • 81. Cin – Input from the Keyboard: • • • • cin stands for console in It is used to accept input data from keyboard. It can read only one word at a time It is also known as extraction / get from operator syntax :- cin>>variable name; Ex:- cin>>x1>>x2; We obtain input from the keyboard through the stream cin ,using the extraction operator >> . CM505.7 81
  • 82. Example To read two integer values from the keyboard into integer variables num1 and num2, we can write as follows: Cin>>num1>>num2; CM505.7 82
  • 83. Example : Contd.. Object Cin Keyboard Extraction Operator >> Variable 45.5 Fig 7.1 :- Input using extraction operator CM505.7 83
  • 84. Description : • “>>” this operator is known as extraction operator. • The operation will be in the direction of the data flow. • The input statement executes from left to right. • It extracts the value from the keyboard and assigns it to the variable on its right. • We can overload this operator CM505.7 84
  • 85. Description (contd..): • Floating point values are read from the keyboard in exactly the same way as integers. • We can also mix the two. • The stream input and operations automatically deal with variables and any data type. CM505.7 85
  • 86. Description (contd..): For exmple, look at the statements: int num1=0,num2=0; double factor=0.0; cin>>num1>>factor>>num2; The last line will read an integer into num1, then a floating point value into factor and finally an integer into num2. CM505.7 86
  • 87. Cout – Output to the display : • Cout is a predefined object that represents the standard output stream in C++. • The standard output stream is screen • It is also possible to redirect the o/p to other o/p devices • It is reverse of cin . • The operator “<<“ is also called as insertion / put to operator CM505.7 87
  • 88. Screen Cout Object << Insertion Operator “C++” Variable Fig 7.2 :- Output using insertion operator CM505.7 88
  • 89. Description : syn:- cout<<variable name; Ex:- cout<<x1<<x2; If x1= 1234 & x2= 5678 ,then output will be “12345678”. CM505.7 89
  • 90. Description (contd..): • The object cout has a simple interface. • It inserts the contents of the variable on its right to the object on its left. • If name represents a string variable, then the following statement will display its contents: cout << name; CM505.7 90
  • 91. Description (contd..): • We can also use this operator for overloading • This concept is known as Operator Overloading, an important aspect of polymorphism. • We can also use printf() statement in C++ CM505.7 91
  • 92. Manipulator • These are the operators that are used to format the data display. • These are defined in the header file iomanip.h • The most commonly used manipulators are setw & endl CM505.7 92
  • 93. Set width or setw(n) Definition : It is an io manipulator which will output the value right justified in a ‘n’ spaces wide. syn:- setw(n); Ex:- cout<<setw(6)<<x1<<setw(7)<<x2; CM505.7 93
  • 94. Escape sequence Definition : These are the execution character set & starts with a ‘’ character set. For ex:- cout <<endl<<“Hello”; cout<<endl<<“t Hello”; Output : Hello Hello CM505.7 94
  • 95. OBJECTIVES On completion of this period, you would be able to learn… • Comment statements in C • Comment statement in C++ • Keywords of C++ other than C CM505.8 95
  • 96. RECAP • What is meant by comment ? • What is keyword ? • List keywords in C ? CM505.8 96
  • 97. Comments in C++ • A comment is used for the documentation purpose. • Comment starts with a double slash symbol(//) and terminates at the end of the line. • It may start any where in the line. • There is no closing for a comment. • Comments are not executable. • All comments are ignored by the compiler. CM505.8 97
  • 98. Comments in C++ There are two ways of writing a comment. • Single line comment. Eg:- // write a program to add two numbers. • Multi line comment. Eg:- /* write a program • to add two • numbers */ CM505.8 98
  • 99. Comment statements in C • C programmers are familiar with the /*..*/ style of commenting. • Anything lying within the /*..*/ pair is ignored by the compiler. • Eg:-/*This is the program*/ CM505.8 99
  • 100. Comment statements in C++ For example: //This is an example //of C++ program /* This is an example of C program */ CM505.8 100
  • 101. Comment statements in C NOTE: • You should always comment your programs comprehensively. • The comment should be sufficient for any programmer. CM505.8 101
  • 102. Keyword • Keyword or Reserved word is an identifier. • It is pre-defined to the compiler. • Keyword can’t be used for naming a variable in programming. CM505.8 102
  • 103. Keywords of C++ other than C • • • • • • • • • • • • • • • • class delete friend public catch new template operator CM505.8 try throw private protected inline asm this virtual 103
  • 104. Keywords of C++ other than C • class: It is an improvement over structure of c conceptually, class is a way to bind data and its associated functions together. • delete: Delete object pointed by a pointer must be used on an object created by new operator. CM505.8 104
  • 105. Keywords of C++ other than C • friend: A friend function declared as friend has access to object of the class . It is not to member of any class. • public: It is an access specifier.Members declared public can be accessed freely in the program. CM505.8 105
  • 106. Keywords of C++ other than C • catch: It catches and processes the exception. • new: It is an operator used for allocating memory dynamically. CM505.8 106
  • 107. Keywords of C++ other than C • operator: used in operator function to overload an existing operator. • template: Constructs a family of related functions or classes.They are sometimes called parameterized classes. CM505.8 107
  • 108. Keywords of C++ other than C • try: A block prefaced with keyword try can be throw an exception. • throw: A mechanism for handling exceptions. CM505.8 108
  • 109. Keywords of C++ other than C • private: It is an access specifier.Members declared private can be accessed freely in the program. • protected: It is an access specifier.Members declared protected can be accessed freely in the program. However, such members can be directly inherited directly in a derived class. CM505.8 109
  • 110. Keywords of C++ other than C • inline: In C++ you can declare and define a member function within its class such function is called inline.  asm: You use Asm statements to use assembly language statements in the middle of your C++ source code. CM505.8 110
  • 111. Keywords of C++ other than C • this: It is a pointer.When any object is created, the system on its own sets a pointer to that object.the name of the pointer variable is ‘this’. • virtual: It can be used to make a class or function virtual. CM505.8 111
  • 112. Summary • Comment statements in C • Comment statements in C++ • Keywords of C++ other than C CM505.8 112
  • 114. Frequently used Questions 1. Define a comment? 2. Explain the comment statements in C++? 3. List the keywords of C++ other than C? CM505.8 114
  • 115. Quiz 1. Comment start with a __________symbol. CM505.8 115
  • 116. Quiz 1. Comment start with a Double slash symbol. CM505.8 116
  • 117. Quiz 2. Catch is a keyword of________. CM505.8 117
  • 118. Quiz 2. Catch is a keyword of C++. CM505.8 118
  • 119. Quiz 3. There are ________ways of commenting in C+ +. CM505.8 119
  • 120. Quiz 3. There are Two ways of commenting in C++. CM505.8 120