2. INTRODUCTION
•PROGRAMMERS WRITE INSTRUCTIONS IN VARIOUS PROGRAMMING
LANGUAGES TO PERFORM THEIR COMPUTATION TASKS SUCH AS:
(I) MACHINE LEVEL LANGUAGE
(II) ASSEMBLY LEVEL LANGUAGE
(III) HIGH LEVEL LANGUAGE
3. LEVELS OF PROGRAMMING LANGUAGES
• Machine code or machine language is a set of instructions
executed directly by a computer's central processing unit
(CPU). Every program directly executed by a CPU is made up
of a series of such instructions.
Machine language
• An assembly language is a low-level programming language for a
computer, or other programmable device, in which there is a very
strong correspondence between the language and the
architecture's machine code instructions. Assembly language is
converted into executable machine code by a utility program
known as assembler
Assembly Language
• High-level language is any programming language that
enables development of a program in much simpler
programming context and is generally independent of the
computer's hardware architecture. High-level language has a
higher level of abstraction from the computer
High level
5. CONCEPT OF OBJECT ORIENTED
PROGRAMMING
OOP is an approach or a programming pattern where the programs are
structured around objects rather than functions and logic. It makes the data
partitioned into two memory areas, i.e., Data and functions, and helps make
the code flexible and modular.
Object-oriented programming mainly focuses on objects that are required to
be manipulated. In OOPs, it can represent data as objects that have attributes
and functions.
7. FEATURES OF OBJECT-ORIENTED PROGRAMMING
1. EMPHASIS IS ON DOING RATHER THAN PROCEDURE.
2. PROGRAMS ARE DIVIDED INTO WHAT ARE KNOWN AS OBJECTS.
3. DATA STRUCTURES ARE DESIGNED SUCH THAT THEY CHARACTERIZE THE
OBJECTS.
4. FUNCTIONS THAT OPERATE ON THE DATA OF AN OBJECT ARE TIED
TOGETHER IN THE DATA STRUCTURE.
5. DATA IS HIDDEN AND CAN’T BE ACCESSED BY EXTERNAL FUNCTIONS.
6. OBJECTS MAY COMMUNICATE WITH EACH OTHER THROUGH FUNCTIONS.
7. NEW DATAAND FUNCTIONS CAN BE EASILY ADDED.
8. FOLLOWS BOTTOM-UP APPROACH IN PROGRAM DESIGN.
9. BASIC OBJECT-ORIENTED
PROGRAMMING
•OBJECT • Objects are the basic run-time entities in an object-oriented system.
They may represent a person, a place, a bank account, a table of
data or any item that the program must handle.
• The fundamental idea behind object-oriented approach is to
combine both data and function into a single unit and these units are
called objects.
• The term objects means a combination of data and program that
represent some real word entity. For example: consider an example
named Amit; Amit is 25 years old and his salary is 2500. The Amit
may be represented in a computer program as an object. The data
part of the object would be (name: amit, age: 25, salary: 2500)
10. BASIC OBJECT-ORIENTED
PROGRAMMING
•CLASS •A group of objects that share common properties for
data part and some program part are collectively
called as class.
•In c ++ a class is a new data type that contains
member variables and member functions that operate
on the variables.
11. BASIC OBJECT-ORIENTED
PROGRAMMING
•DATAABSTRACTION
•Abstraction refers to the act of representing essential
features without including the back ground details or
explanations. Classes use the concept of abstraction and
are defined as size, width and cost and functions to operate
on the attributes.
• Data abstraction in object-oriented programming (OOP) is
the practice of hiding complex implementation details
while exposing only essential information to the user.
12. BASIC OBJECT-ORIENTED
PROGRAMMING
•DATA ENCAPSULATION
•The wrapping up of data and
function into a single unit (called
class) is known as encapsulation.
The data is not accessible to the
outside world and only those
functions which are wrapped in the
class can access it. These functions
provide the interface between the
objects data and the program.
13. BASIC OBJECT-ORIENTED
PROGRAMMING
• INHERITENCE
•Inheritance is the process by which
objects of one class acquire the properties
of another class. In the concept of
inheritance provides the idea of
reusablity. This mean that we can add
additional features to an existing class
with out modifying it. This is possible by
desining a new class will have the
combined features of both the classes.
14. BASIC OBJECT-ORIENTED PROGRAMMING
• Polymorphism means the ability to take more than one form. An
operation may exhibit different instance. The behaviour depends
upon the type of data used in the operation.
• A language feature that allows a function or operator to be given
more than one definition. The types of the arguments with which
the function or operator is called determines which definition will
be used.
• Overloading may be operator overloading or function
overloading.
• It is able to express the operation of addition by a single operater
say ‘+’. when this is possible you use the expression x + y to
denote the sum of x and y, for many different types of x and y;
integers , float and complex no. You can even define the +
operation for two strings to mean the concatenation of the strings.
POLYMORPHISM:
15. BASIC OBJECT-ORIENTED PROGRAMMING
•. Binding refers to the linking of a procedure call to the code to the executed
in response to the call. Dynamic binding means the code associated with a
given procedure call is not known until the time of the call at run-time. It is
associated with a polymorphic reference depends upon the dynamic type of
that reference.
DYNAMIC BINDING:
16. BENEFITS OF OOP
• Through inheritance we can eliminate redundant code and extend the use of existing
classes.
• We can build programs from the standard working modules that communicate with one
another, rather than having to start writing the code from scratch.
• This principle of data hiding helps the programmer to build secure programs that can’t be
invaded by code in other parts of the program.
• It is possible to have multiple instances of an object to co-exist with out any interference.
• It is easy to partition the work in a project based on objects.
• Object-oriented systems can be easily upgraded from small to large systems.
APPLICATIONS OF OOP
• 1. Real – time systems.
• 2. Simulation and modeling
• 3. Object oriented databases.
• 4. Hypertext, Hypermedia and expert text.
• 5. Al and expert systems.
• 6. Neural networks and parallel programming.
• 7. Decision support and office automation systems.
• 8. CIM / CAM / CAD system.
17. ADVANTAGES OF OOPS
THERE ARE VARIOUS ADVANTAGES OF OBJECT-ORIENTED PROGRAMMING.
OOPS PROVIDE REUSABILITY TO THE CODE AND EXTEND THE USE OF
EXISTING CLASSES.
IN OOPS, IT IS EASY TO MAINTAIN CODE AS THERE ARE CLASSES AND
OBJECTS, WHICH HELPS IN MAKING IT EASY TO MAINTAIN RATHER THAN
RESTRUCTURING.
IT ALSO HELPS IN DATA HIDING, KEEPING THE DATAAND INFORMATION SAFE
FROM LEAKING OR GETTING EXPOSED.
OBJECT-ORIENTED PROGRAMMING IS EASY TO IMPLEMENT.
18. BASICS OF C++
•C ++ is an object-oriented programming language, C ++ was developed by jarney stroustrup at AT & T bell lab,
USA in early eighties. C ++ was developed from c and simula 67 language.
•C++ COMMENTS
•C++ introduces a new comment symbol //(double slash). Comments start with a double slash symbol and terminate
at the end of line.
// This is an example of
// c++ program
// thank you
19. BASICS OF C++
• OUTPUT OPERATOR: The statement cout <<”hello, world” displayed the string with in quotes on the screen.
The identifier cout can be used to display individual characters, strings and even numbers. It is a predefined object
that corresponds to the standard output stream. Stream just refers to a flow of data and the standard output stream
normally flows to the screen display. The cout object, whose properties are defined in iostream.h represents that
stream.
• RETURN STATEMENT: In C++ main ( ) returns an integer type value to the operating system. Therefore every
main ( ) in C++ should end with a return (0) statement, otherwise a warning or an error might occur.
• INPUT OPERATOR: The statement cin>> number 1;
Is an input statement and causes. The program to wait for the user to type in a number. The number keyed in is placed
in the variable number1. The identifier cin is a predefined object in C++ that corresponds to the standard input stream.
Here this stream represents the key board.
20. STRUCTURE OF A PROGRAM IN C++
•// My first program in C++
•#include <iostream>
•Using namespace std;
•Int main ()
•{
•Cout << "hello world!";
•Return 0;
•}
OUTPUT:-HELLO WORLD!
21. STRUCTURE OF C++ PROGRAM WITH OOP
• EXAMPLE :-
# Include<iostream.h>
Class Human {
Public:
std::string name;
std::string occupation;
int age;
void eat(){
std::cout << “This person is eatingn;
}
void drink(){
std::cout << “This person is drinkingn;
};
int main(){
Human human1;
human1. name = “Rick”
human1.occupation = “scientist”;
human1.age = 70;
std::cout <<human1.name << ‘n’;
std::cout <<human1.occupation << ‘n’;
std::cout <<human1.age << ‘n’;
human1.eat()
human1.drink()
return 0;
;
22. STRUCTURE OF C++ PROGRAM WITH OOP
• EXAMPLE :-
# Include <iostream>
Class Car {
Public:
std::string Make;
std::string model
int age;
void accelerate(){
std::cout << “You step on the Gas!n;
}
void brake(){
std::cout << “You step on the brakes!n;
};
int main(){
Car car1;
car1.make = “Ford”;
car1.model= “Mustang”;
car1.year = 2024;
std::cout <<car1.make<< ‘n’;
std::cout <<car1.model<< ‘n’;
std::cout <<car1.year<< ‘n’;
car1.accelerate()
car1.brake()