0% found this document useful (0 votes)
15 views

OOP Introduction

Computers take data as input, process that input, and produce results. There are different types of data that can be input including variables, arrays, strings, and structures. The processing of data involves sequential logic, selection logic using conditional statements, and iterative logic using loops. Functions are also used to break processing into reusable steps. Object-oriented programming uses objects that contain data properties and functions. Classes are used to create objects, with classes defining the data attributes and functions of the object.

Uploaded by

Haider Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

OOP Introduction

Computers take data as input, process that input, and produce results. There are different types of data that can be input including variables, arrays, strings, and structures. The processing of data involves sequential logic, selection logic using conditional statements, and iterative logic using loops. Functions are also used to break processing into reusable steps. Object-oriented programming uses objects that contain data properties and functions. Classes are used to create objects, with classes defining the data attributes and functions of the object.

Uploaded by

Haider Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

INTRODUCTION

Computers takes data as input process that input and produces results.
Data Process
1. Variables ( int , float, double, long etc) 1. Sequence logic, or sequential flow
2. Arrays (Consecutive Group of memory Cells) 2. Selection logic, or conditional flow
-- A Collection of more than one variables of the same  If , if-else, multi-if, switch
data type
3. Iteration logic, or repetitive flow
3. Strings (A collection of Characters)  For, while and do-while Loops

4. Strucutre (A collection of more than one 4. Function Call


variable of different  Control moves outside main(), performs some
task and returns back
types.)
(OOP)
Objects

collection Data Properties

• Data variables
• Properties functions
data procedures single
object
entity
• Data
• Functions
• The Standard Function Library:

• The Object Oriented Class Library

The Standard Function Library:


entity
identified name

• Properties characteristics
• Function actions
Characteristics/Properties attributes

Actions functions methods

Manufacturer
Name Color
Age Properties Price
Weight Model
Person Vehicle
Start
Walk
Functions Stop
Talk
Accelerate
eat
Reverse
user-defined
data members member functions
accessed used creating instance
blueprint

• member functions
keyword class
class declaration variables functions

variables member variable data


members
functions member functions
• Data Hiding
• Data hiding restricting access data members
tampering

important accessible
hidden manipulated indirectly
• Data Hiding
• Data hiding restricting access data members
tampering

important accessible
hidden manipulated indirectly
Access Specifier
Methods are functions that belongs to the class.
There are two ways to define functions that belongs to a class:
•Inside class definition
•Outside class definition
In the following example, we define a function inside the class, and we name it "myMethod".
In C++, an object is created from a class. We have already created the class named MyClass, so now we can use this to create objects.
To create an object of MyClass, specify the class name, followed by the object name.
To access the class attributes (myNum and myString), use the dot syntax (.) on the object:

You might also like