Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,

Slides:



Advertisements
Similar presentations
Classes & Objects INTRODUCTION : This chapter introduces classes ; explains data hiding, abstraction & encapsulation and shows how a class implements these.
Advertisements

Based on Java Software Development, 5th Ed. By Lewis &Loftus
1 Classes and Data Abstraction Chapter What a Class ! ! Specification and implementation Private and public elements Declaring classes data and.
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Classes and Objects Systems Programming.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Classes, Encapsulation, Methods and Constructors Class definitions Scope of Data –Instance data –Local data The this Reference Encapsulation and Java.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Fall 2007ACS-1903 Chapter 6: Classes Classes and Objects Instance Fields and Methods Constructors Overloading of Methods and Constructors Scope of Instance.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Software Engineering Principles and C++ Classes
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Abstract Data Types and Encapsulation Concepts
1 Using Classes Object-Oriented Programming Using C++ Second Edition 5.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to Classes and Objects Outline Introduction Classes, Objects, Member Functions and Data.
Writing Classes (Chapter 4)
Unified Modeling Language, Version 2.0
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Introduction To Classes Chapter Procedural And Object Oriented Programming Procedural programming focuses on the process/actions that occur in a.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13: Introduction to Classes.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
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.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
1 Introduction to Classes and Objects Chapter 3 Introduction to Classes and Objects Chapter 3.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 02] Introduction to.
Chapter 11: Introduction to Classes. In this chapter you will learn about: – Classes – Basic class functions – Adding class functions – A case study involving.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Chapter 3 (B) 3.5 – 3.7.  Variables declared in a function definition’s body are known as local variables and can be used only from the line of their.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7: Introduction to Classes and Objects Starting Out with C++ Early.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
計算機程式語言 Lecture 03-1 國立台灣大學生物機電系 林達德 3 3 Introduction to Classes and Objects.
Classes, Interfaces and Packages
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 13: Introduction to Classes.
An Introduction to Programming with C++ Fifth Edition Chapter 14 Classes and Objects.
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
Introduction to Classes and Objects CS-2303, C-Term C++ Program Structure Typical C++ Programs consist of:– main –A function main –One or more classes.
Chapter 11: Abstract Data Types Lecture # 17. Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Introduction to Object-oriented Programming
Chapter 3: Using Methods, Classes, and Objects
About the Presentations
Introduction to Classes
Abstract Data Types and Encapsulation Concepts
Introduction to Classes
Chapter 3 Introduction to Classes, Objects Methods and Strings
Basic C++ What’s a declaration? What’s a definition?
Corresponds with Chapter 7
Classes and Data Abstraction
Introduction to Classes and Objects
Object-Oriented Programming
Classes and Objects Systems Programming.
Object Oriented Programming
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Introduction to Classes and Objects
Presentation transcript:

Chapter 10 Classes and Objects In-Depth

Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes, or characteristics, and behavior of the class. –At the abstract level, a class can be described as an interface that defines the behavior of its objects. –At the implementation level, a class is a syntactical unit that describes a set of data and related operations that are common to its objects.

Chapter 10 CLASS DECLARATION FORMAT class name { //FUNCTION MEMBERS public: Function prototypes go here. //DATA MEMBERS private: Variable definitions go here. }; //END CLASS

Chapter 10 The public class functions form the interface to the class and are accessible from outside the class. Public functions are used to provide access to and manipulate the private class members. A private class member is only accessible within the class by functions of the same class.

Chapter 10 Encapsulation means to package data and/or operations into a single well-defined programming unit.

Chapter 10 Information hiding means that there is a binding relationship between the information, or data, and its related operations so that operations outside the encapsulated unit cannot affect the information inside the unit.

Chapter 10 The Unified Modeling Language, or UML, is a technique for analyzing and designing object-oriented software.

Chapter 10 UML diagram for a SavingsAccount class

Chapter 10 An object is an instance, or specimen, of a given class. An object of a given class has the structure and behavior defined by the class that is common to all objects of the same class.

Chapter 10 Object Definition Format class name object name;

Chapter 10 A function implementation is the definition of the function that includes the function header and the body of the function.

Chapter 10 Format for a Function Implementation return type class name :: function name (parameter listing) { //BODY OF FUNCTION GOES HERE }//END FUNCTION

Chapter 10 A constructor is a special class function that is used to initialize an object automatically when the object is defined.

Chapter 10 Constructor Format

Chapter 10 All the member functions of a class carry with them an invisible pointer, called this, that points to the object that called the function.

Chapter 10 An access function, sometimes called a get function, is a function that returns only the values of the private members of an object.

Chapter 10 A message is a call to a member function.

Chapter 10 A type cast converts data of one type to a different type, temporarily. You can convert data of one type to another type by preceding the data variable/expression with the type to convert to within parentheses like this: winPercent = (double)wins/(wins + losses) * 100;

Chapter 10 A project file identifies the files that need to be compiled and linked to create a given executable program.

Chapter 10 A multi-file Project