Object-Oriented Programming in C++/Handout 01 Page 1 of 8

Similar documents
Object oriented programming Concepts

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

What is a Programming Paradigm

1. Write two major differences between Object-oriented programming and procedural programming?

Object Oriented Programming

Overview. OOP: model, map, reuse, extend. Examples of objects. Introduction to Object Oriented Design

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

OOAD - OBJECT MODEL. The concepts of objects and classes are intrinsically linked with each other and form the foundation of object oriented paradigm.

2D1358 Object Oriented Program Construction in C++ Exercises & Labs. Course Registration / Accounts. Course Literature

What are the characteristics of Object Oriented programming language?

Data Structures (list, dictionary, tuples, sets, strings)

CHAPTER 5 GENERAL OOP CONCEPTS

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

CSC Inheritance. Fall 2009

Object Oriented Software Development CIS Today: Object Oriented Analysis

Abstraction. Abstraction

C++ Programming: Introduction to C++ and OOP (Object Oriented Programming)

Fundamental Concepts (Principles) of Object Oriented Programming These slides are based on:

From Module To Objects

Chapter3: Introduction to Classes and Objects


Inheritance and Polymorphism

Object-Oriented Programming Paradigm

OBJECT ORIENTED PROGRAMMING

9/21/2010. Based on Chapter 2 in Advanced Programming Using Visual Basic.NET by Bradley and Millspaugh

System Analysis and Design/ Object-Oriented System Modeling


Sorting. Sorting. Selection sort

The Essence of Object Oriented Programming with Java and UML. Chapter 2. The Essence of Objects. What Is an Object-Oriented System?

CSC207H: Software Design SOLID. CSC207 Winter 2018

Experiment no 4 Study of Class Diagram in Rational Rose

Introduction to Object-Oriented Programming

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

Solved Question Paper June 2017

Lab Manual. Object Oriented Analysis And Design. TE(Computer) VI semester

Object- Oriented Design with UML and Java Part I: Fundamentals

Basics of Object Oriented Programming FCITR MAGAZINE DR. SHAKEEL AHMAD

Advantages of Object Oriented Programming :- Features of Object Oriented Programming :- Advantages Of Object Oriented Programming :

CMSC201 Computer Science I for Majors

SEEM4570 System Design and Implementation. Lecture 11 From Design to Implementation

CSCI 253. Outline. Background. George Blankenship 1

Object-Oriented Systems Analysis and Design Using UML

Introducing the UML Eng. Mohammed T. Abo Alroos

Object Oriented Programming. Michał Bereta

MechEng SE3 Lecture 7 Domain Modelling

Object Orientated Programming Details COMP360

Chapter 12 Object-Oriented Programming. Starting Out with Games & Graphics in C++ Tony Gaddis

Object Oriented Programming Using C ++ Page No. : 1. ASSIGNMENT SHEET WITHOUT USING OBJECT AND CLASSES

Chapter No. 2 Class modeling CO:-Sketch Class,object models using fundamental relationships Contents 2.1 Object and Class Concepts (12M) Objects,

Object-Oriented Design

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

For 100% Result Oriented IGNOU Coaching and Project Training Call CPD TM : ,


Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)

Object Oriented Programming. C++ 6 th Sem, A Div Ms. Mouna M. Naravani

Suggested answers are provided below. These answers are presented top-down, left to right.

Software Development. Modular Design and Algorithm Analysis

Object Oriented Analysis is popular approach that sees a system from the viewpoint of the objects themselves as they function and interact

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

Lab Manual Object Oriented Programming with JAVA (15ECSP203)

Introduction to UML What is UML? Motivations for UML Types of UML diagrams UML syntax Descriptions of the various diagram types Rational Rose (IBM.. M

Elementary Concepts of Object Class

What is Inheritance?

CSC148H Week 1 >> COURSE INFORMATION, RECAP, OOP. Sadia Rain Sharmin Week of May 7, 2018

Introduction to Computers and Java

An Introduction To Object Modeling System Concept for Object Modeling The Overall View Components of UML Diagram

06. Analysis Modeling

Object-Oriented Programming


Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

Introduction to Computers and Java

CASE TOOLS LAB VIVA QUESTION

Syllabus for Bachelor of Technology. Computer Engineering. Subject Code: 01CE1303. B.Tech. Year - II

JAVA: A Primer. By: Amrita Rajagopal

Inheritance, and Polymorphism.

Chapter 15: Object Oriented Programming

8.0. Classes and Classification In the real world

Introduction to OOP. Procedural Programming sequence of statements to solve a problem.

Introduction to Computers and Java

INHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U

COMPUTER PROGRAMMING (ECE 431) TUTORIAL 9

Data Structures (INE2011)

PROGRAMMING IN C AND C++:

OBJECT ORIENTED SYSTEM DEVELOPMENT Software Development Dynamic System Development Information system solution Steps in System Development Analysis

Computer Science 4U Unit 1. Programming Concepts and Skills Modular Design

Programming in C# Inheritance and Polymorphism

Object Oriented Programming using C++

Software Architecture (Lesson 2) Object-Oriented Paradigm (1)

Chapter 1: Object-Oriented Programming Using C++

ECE 462 Object-Oriented Programming using C++ and Java. Key Inputs in Java Games

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

Class Diagram. Classes consist of. Note that class diagrams contain only classes, not objects.

modeling essential properties treat what and how independently building complex structures from simpler ones identifying common elements

Design Strategies in OO Development

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

Back to ObjectLand. Contents at: Chapter 5. Questions of Interest. encapsulation. polymorphism. inheritance overriding inheritance super

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism


OO System Models Static Views

Transcription:

Object-Oriented Programming in C++/Handout 01 Page 1 of 8 Table of Contents Table of Contents... 1 Learning Objectives... 2 Object-Oriented Approach... 2 Advantages of Object-Oriented Approach... 2 Principles of Object Orientation... 2 Object... 2 Examples of Objects... 4 Encapsulation... 5 Class... 6 Inheritance... 6 Polymorphism... 8 Reference for Further Reading... 8

Object-Oriented Programming in C++/Handout 01 Page 2 of 8 Learning Objectives After completing this handout, you will be able to: Understand object-oriented programming. Understand classes and objects. Understand principles of object-oriented approach. Understand encapsulation, inheritance, and polymorphism. Object-Oriented Approach Structured programming presented some challenges for which object-oriented programming was designed to solve. With object-oriented programming, developers create blocks of code, called objects. With the object-oriented approach, you divide an application into many small chunks, or objects, that are fairly independent of one another. With the object-oriented approach, we focus on both information and behavior. The fundamental idea behind object-oriented languages is to combine into a single unit both data and the functions that operate on that data. Such as unit is called an object. Advantages of Object-Oriented Approach One of the primary advantages of the object-oriented paradigm is the ability to build components once and then use them over and over again. This is called reusability. Principles of Object Orientation Encapsulation Inheritance Polymorphism Object An object s functions, called member functions in C++, typically provide the only way to access its data. If you want to access a data stored in an object, you call a member function of that object. You cannot access the data stored in objects directly.

Object-Oriented Programming in C++/Handout 01 Page 3 of 8 The data is said to be hidden inside the object and is safe from accidental alteration. A C++ program typically consists of a number of objects, which communicate with each other by calling one another s member functions. Think of objects as departments such as sales, accounting, personnel, and so on in a company.

Object-Oriented Programming in C++/Handout 01 Page 4 of 8 In OOP, the concept of inheritance provides an important extension to the idea of reusability. Examples of Objects Physical objects Automobiles in a traffic-flow simulation Electrical components in a circuit-design program Countries in an economical model Aircraft in an air-traffic control system Elements of the computer-user environment Windows Menus Graphics objects (lines, rectangles, circles) The mouse, keyboard, disk drives, printer Data-storage constructs Customized arrays

Object-Oriented Programming in C++/Handout 01 Page 5 of 8 Stacks Lined lists Binary trees Human entities Employees Students Customers Salespeople Collections of data An inventory A personnel file A dictionary A table of the latitudes and longitudes of world cities User-defined data types Time Angles Complex numbers Points on the plane Components in computer games Ghost in a maze game Positions in a board game (chess, checkers) Animal in an ecological simulation Opponents and friends in adventure games Encapsulation In object-oriented systems, we combine a piece of information with the specific behavior that acts upon that information. Then we package these into an object. This is referred to as encapsulation. For example, we have information relating to a bank account, such as the account number, balance, customer name, address, account type, interest rate, and opening date. We also have behavior for a bank account: open, close, deposit, withdraw, change type, change customer, and change address. We encapsulate this information and behavior together into an account object. A concept similar to encapsulation is information hiding. Information hiding is the ability to hide the murky details of an object from the outside world.

Object-Oriented Programming in C++/Handout 01 Page 6 of 8 Data and its functions are said to be encapsulated into a single entity called an object. Data encapsulation and data hiding are key terms in the description of objectoriented languages. Class Objects are members of classes. You can define many objects of the same class. A class serves as a plan, or template. It specifies what data and what functions will be included in objects of that class. Defining a class does not create any object. A class is a collection of similar objects. Classes lead to inheritance because classes are divided into subclasses. For example class of animals is divided into mammals, amphibians, insects, birds, and so on. Similarly, class of vehicle is divided into cars, trucks, buses, and motorcycles. Inheritance In object-oriented systems, inheritance is a mechanism that lets you create new objects based on old ones: The child object inherits the qualities of a parent object. You can see examples of inheritance in the natural world. There are hundreds of different types of mammals: dogs, cats, humans, whales, and so on. Each of these has certain characteristics that are unique and certain characteristics that are common to the whole group, such as having hair, being warm-blooded, and nurturing their young. In object-oriented terms, there is a mammal object that holds the common characteristics. This object is the parent of the child objects cat, dog, human, whale, etc. The dog object inherits the characteristics of the mammal object, and has some additional dog characteristics of its own, such as running in circles and slobbering.

Object-Oriented Programming in C++/Handout 01 Page 7 of 8 One of the major benefits of inheritance is ease of maintenance. When something changes that affects all mammals, only the parent object needs to change the child objects will automatically inherit the changes. In an object-oriented system, an example of inheritance might be in the windows. In a banking system, we might use inheritance for the different types of accounts we have. In C++ the original class is called the base class; other classes can be defined that share its characteristics, but ass their own as well. These are called derived classes. Each subclass shares common characteristics with the class from which it s derived. In addition to the characteristics shared with other members of the class, each subclass also has its own particular characteristics.

Object-Oriented Programming in C++/Handout 01 Page 8 of 8 Polymorphism The dictionary defines it as the occurrence of different forms, stages, or types. Polymorphism means having many forms or implementations of a particular functionality. In terms of an object-oriented system, this means that we can have many implementations of a particular functionality. Reference for Further Reading Mastering UML with Rational Rose 2002, Wendy Boggs and Michael Boggs, Chapter 1. Object-Oriented Programming in C++, Second Edition, Robert Lafore, Chapter 1.