OOP Introduction
OOP 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
• Data variables
• Properties functions
data procedures single
object
entity
• Data
• Functions
• The Standard Function Library:
• Properties characteristics
• Function actions
Characteristics/Properties attributes
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
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: