Download presentation
Presentation is loading. Please wait.
1
Object Oriented Programming
Lecture 14 Object Oriented Programming
2
Introduction What is object oriented programming? Example:
Abstraction Encapsulation Inheritance Example: Think about an object in real world Mobile
3
Structure We define struct in previous lecture.
You can encapsulate data about an object in a new data type. Example:
4
Class Classes are an expanded concept of data structures
they can contain data members. they can also contain functions as members. Function show behavior of an object.
5
Example
6
Example
7
Public and Private attribute/Function
Object can have attribute with private access and public access from outside of view. Think about mobile. What is public? What is private? So we can have several type of access in OOP.
8
Syntax
9
Define and usage To define an object from class: Example
<class name> <object name>; Example Usage: like structs: . Operator for normal object. -> operator for pointer object.
10
Initialization and destroy
We can define two special function: First: when execute, initialize object. Second: when execute, destroy object. Syntax: Initializer: A function without data type and same name of class. Destroyer: A function without data type, ~same name of class
11
Example
12
Example
14
Input Output in C++ We can use cin and cout for input/output in c++.
Syntax: For input: cin>> variable_name; For output Cout<< variable_name;
15
Overloading Can we define two function with same name?
Yes, but parameter must be different.
16
What is wrong?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.