C++ Classes C++ Interlude 1 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.

Slides:



Advertisements
Similar presentations
Lists Chapter 8 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Advertisements

Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
CS Data Structures Chapter 8 Lists Mehmet H Gunes
C++ data types. Structs vs. Classes C++ Classes.
16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted.
Mutable, Immutable, and Cloneable Objects Chapter 15 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
C++ Interlude 2 Pointers, Polymorphism, and Memory Allocation
Sorted Lists and Their Implementations Chapter 12 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 3 Array-Based Implementations CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Stacks Chapter 6 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Data Abstraction: The Walls
C++ Polymorphism Systems Programming. Systems Programming: Polymorphism 2   Polymorphism Examples   Relationships Among Objects in an Inheritance.
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.
1 Classes- Inheritance Multiple Inheritance It is possible to derive a new class from more than one base class. This is called Multiple Inheritance. Under.
Queues and Priority Queues
Implementations of the ADT Stack Chapter 7 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 6 Stacks CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Trees Chapter 15 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Recursion as a Problem- Solving Technique Chapter 5 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 8: Class Relationships Data Abstraction & Problem Solving.
Tree Implementations Chapter 16 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Inheritance, Polymorphism, And Virtual Functions Chapter 15.
Copyright © 2012 Pearson Education, Inc. Chapter 15: Inheritance, Polymorphism, and Virtual Functions.
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.
Class Relationships And Reuse Interlude 4 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Interfaces Chapter 9. 9 Creating Interfaces An interface is a contract. Every class that implements the interface must provide the interface’s defined.
Heaps Chapter 17 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7: Introduction to Classes and Objects Starting Out with C++ Early.
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Array-Based Implementations Chapter 3 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Objects with Functions and Arrays. Objects can be Passed Class defines type – Can use as type of function or parameter.
Inheritance Chapter 11 in Gaddis. Is a relationships in ‘real’ life Exist when one object is a specialized version of another one –Examples An english.
Interlude 1 C++ Classes CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Abstract classes only used as base class from which other classes can be inherit cannot be used to instantiate any objects are incomplete Classes that.
Queues and Priority Queue Implementations Chapter 14 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 4 Link Based Implementations
Link Based Implementations
Chapter 2 Objects and Classes
© 2017 Pearson Education, Hoboken, NJ. All rights reserved
CS 215 Final Review Ismail abumuhfouz Fall 2014.
DATA ABSTRACTION AND PROBLEM SOLVING WITH C++
More about OOP and ADTs Classes
Chapter 16 Tree Implementations
C++ Classes C++ Interlude 1
C++ Classes C++ Interlude 1.
Exceptions C++ Interlude 3
Implementations of the ADT Stack
Chapter 4 Link Based Implementations
Classes and Data Abstraction
List Implementations Chapter 9
More about OOP and ADTs Classes
C++ Interlude 1 C++ Classes
Stacks Chapter 6 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Objects with Functions and Arrays
Array-Based Implementations
Sorted Lists and Their Implementations
Array-Based Implementations
Fundaments of Game Design
Chapter 8: Class Relationships
CIS 199 Final Review.
Chapter 2. Problem Solving and Software Engineering
Queues and Priority Queue Implementations
Final Exam Review Inheritance Template Functions and Classes
ENERGY 211 / CME 211 Lecture 22 November 10, 2008.
C++ data types.
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Presentation transcript:

C++ Classes C++ Interlude 1 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Contents A Problem to Solve Implementing a Solution Templates Inheritance Virtual Methods and Abstract Classes Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

A Problem to Solve Creating a video game with a group of classes to represent three types of boxes  Plain box  Toy box  Magic box Begin by designing an ADT plain box  Use aspects of its implementation for the other two boxes View header file, Listing C1-1Listing C1-1.htm code listing files must be in the same folder as the.ppt files for these links to work Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Class Declarations Private Data Fields Constructors and Destructors Methods  Accessor methods  Mutator methods  Passing parameters by constant reference. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Class Declarations Guidelines for safe and secure programming Declare data fields as private Declare as const any method that does not change the object Declare any parameter passed by reference as const  Unless you are certain it must be modified by the method Preventing Compiler Errors Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Implementing a Solution View Listing C1-2 Implementation file for the PlainBox classListing C1-2 Note a template version, Listing C1-3Listing C1-3 Implementation file for the PlainBox template class, Listing C1-4Listing C1-4 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Inheritance Base Classes and Derived Classes View Listing C1-5, Template header fi le for the class ToyBoxListing C1-5 And the implementation file, Listing C1-6Listing C1-6 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Overriding Base-Class Methods Redefine inherited methods Example, Listing C1-7 Header file for the class MagicBoxListing C1-7 And the implementation, Listing C1-8Listing C1-8 Consider abstract class, an interface for the ADT Box, Listing C1-9 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

End Chapter C++ Interlude 1 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013