7.7.7.7. Seventh step for Learning C++ Programming CLASS Declaration Public & Private Constructor & Destructor This pointer Inheritance.

Slides:



Advertisements
Similar presentations
Final and Abstract Classes
Advertisements

Introduction to Programming Lecture 39. Copy Constructor.
C++ Classes & Data Abstraction
OOP: Inheritance By: Lamiaa Said.
Inheritance Java permits you to use your user defined classes to create programs using inheritance.
EEM 480 Algorithms and Complexity by Assist. Prof. Dr. Emin Germen.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C# Programming: From Problem Analysis to Program Design1 Creating Your Own Classes C# Programming: From Problem Analysis to Program Design 3rd Edition.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
Introduction to Data Structures, Spring 2007 Slide- 1 California State University, Fresno Introduction to Data Structure Object Oriented Programming Concepts.
ASP.NET Programming with C# and SQL Server First Edition
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
C++ Classes & Object Oriented Programming. Object Oriented Programming  Programmer thinks about and defines the attributes and behavior of objects. 
Inheritance using Java
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Chapter 15 – Inheritance, Virtual Functions, and Polymorphism
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Inheritance Joe Meehean. Object Oriented Programming Objects state (data) behavior (methods) identity (allocation of memory) Class objects definition.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Chris Kiekintveld CS 2401 (Fall 2010) Elementary Data Structures and Algorithms Inheritance and Polymorphism.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
 Classes in c++ Presentation Topic  A collection of objects with same properties and functions is known as class. A class is used to define the characteristics.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
CSC241 Object-Oriented Programming (OOP) Lecture No. 4.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Copyright © 2002 W. A. Tucker1 Chapter 10 Lecture Notes Bill Tucker Austin Community College COSC 1315.
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
Object Oriented Programming
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
1 COSC2007 Data Structures II Chapter 9 Class Relationships.
Object-Oriented Programming (OOP) What we did was: (Procedural Programming) a logical procedure that takes input data, processes it, and produces output.
© 2007 Lawrenceville Press Slide 1 Chapter 9 Inheritance  One class is an extension of another.  Allows a class to define a specialized type of an existing.
CS 139 Objects Based on a lecture by Dr. Farzana Rahman Assistant Professor Department of Computer Science.
Classes, Interfaces and Packages
Computer Programming 2 Lecture 8: Object Oriented Programming Creating Classes & Objects Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
By : Robert Apeldorn. What is OOP?  Object-oriented programming is a programming paradigm that uses “objects” to design applications and computer programs.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
1 Introduction to Object Oriented Programming Chapter 10.
YG - CS Concept of Encapsulation What is encapsulation? - data and functions/methods are packaged together in the class normally.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
COMPUTER SCIENCE & TECHNOLOGY DEGREE PROGRAMME FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UVA WELLASSA ‏ Properties of Object Oriented Programming.
1 C++ Classes & Object Oriented Programming Overview & Terminology.
CS 116 Object Oriented Programming II Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
A First Book of C++ Chapter 12 Extending Your Classes.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Data Structures Lecture 4: Classes in C++ Azhar Maqsood NUST Institute of Information Technology (NIIT)
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
One class is an extension of another.
Road Map Introduction to object oriented programming. Classes
Introduction to Object-oriented Program Design
3 Fundamentals of Object-Oriented Programming
C++ Classes & Object Oriented Programming
Object Oriented Analysis and Design
Can perform actions and provide communication
One class is an extension of another.
Eleventh step for Learning C++ Programming
Implementing Classes Chapter 3.
C++ Programming ㅎㅎ String OOP Class Constructor & Destructor.
Object oriented programming (OOP) Lecture No. 7
By Rajanikanth B OOP Concepts By Rajanikanth B
C++ Programming CLASS This pointer Static Class Friend Class
Types of Computer Languages
ㅎㅎ Sixth step for Learning C++ Programming Pointer new, delete String
Presentation transcript:

Seventh step for Learning C++ Programming CLASS Declaration Public & Private Constructor & Destructor This pointer Inheritance

2 2 OOP (Object Oriented Programming) OOP? (Object Oriented Programming) - -To recognize all of the data as an object, an object can be operated independently, while other objects, also available as a component to the progra m. Programming available as a component of other objects Abstraction, 추상화 Encapsulation, 캡슐화 Informationhiding, 데이터 은닉 Inheritance, 상속 Polymorphism, 다형

3 10 / Class: Object Types A C++ class is an object type. Objects are structures that allocate memory during program execution An objects is instance of some class and is created during runtime by special statements When you create the definition of a class you are defining the attributes and behavior of a new type. Attributes are data members. Behavior is defined by methods.

4 4 CLASS The composition of the class -The class is blueprint of the object. -The class is composed member variables(or fields) and member functions(or methods) -Member variable represents the properties of object -Member function represents the behavior of object

5 5 CLASS CLASS Declaration class ClassName (The first character of ClassName is uppercase) { AccessControl Keyword: MemberVariables; MemberFunctions; }; ClassName ObjectName; ObjectName.MemberFunction

6 6 [ practice 1 Class ]

7 7 [ explain 1 Class ]

8 8 [ practice 2 Public & Private ]

9 9

10 [ practice 2 Public & Private ]

11 10 / Special Member Functions Constructors: called when a new object is created (instantiated). can be many constructors, each can take different arguments. Destructor: called when an object is eliminated only one, has no arguments.

12 [ practice 3 Constructor & Destructor ]

13 [ practice 3 Constructor & Destructor…continue ]

14 [ explain 3 Constructor & Destructor ]

15 [ practice 4 Various Ojects ]

16 [ explain 4 Various Ojects ]

17 [ practice 5 Do you want to attack a monster? ]

18 [ practice 5 Do you want to attack a monster? ]

19 [ practice 5 Do you want to attack a monster? ]

20 [ explain 5 Do you want to attack a monster? ]

21 11 / this-pointer this returns always a reference to the current object. Example: Circle::Circle(double radius) { this -> radius = radius; } radius of the current (new) object constructor’s argument

22 11 / this-pointer class AAA{ private: int a; char c; double d; void set(AAA *pa) { cin >> pa -> a; cin >> pa -> c; cin >> pa -> d; class AAA{ private: int a; char c; double d; void set() //void set(AAA *this) { cin >> this -> a; cin >> this -> c; cin >> this -> d;

23 [ practice 6 this pointer ]

24 [ explain 6 this pointer ]

25 11 / Inheritance You can create a new class that inherits from an existing class. The new class is a specialization of the existing class (called subclass). You can add new members and methods. You can replace methods. Motivation: Reuse of existing code

26 11 / Inheritance Example: You have a class that represents “circles". Create a new class that represents “cylinders". Most of the behavior and attributes are the same, but a few are different/new (height of cylinder, different area computation, volume)

27 11 / Inheritance Example A Cylinder is a extended (specialized) form of a Circle. radius height Circle Cylinder

28 [ practice 7 inheritance ]

29 [ practice 7 inheritance…continue ]

30 [ explain 7 inheritance ]

Thank you