Enviar búsqueda
Cargar
Data abstraction the walls
•
Descargar como PPT, PDF
•
1 recomendación
•
456 vistas
H
Hoang Nguyen
Seguir
Data abstraction the walls
Leer menos
Leer más
Tecnología
Denunciar
Compartir
Denunciar
Compartir
1 de 44
Descargar ahora
Recomendados
Abstract data types
Abstract data types
Poojith Chowdhary
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
St Mary's College,Thrissur,Kerala
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt) intro to data structure part 2
Self-Employed
Abstract Data Types
Abstract Data Types
karthikeyanC40
Introduction to data structure
Introduction to data structure
Vivek Kumar Sinha
Slide 1.-datastructure
Slide 1.-datastructure
Minhaz Leo
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
Kathirvel Ayyaswamy
Algo>Abstract data type
Algo>Abstract data type
Ain-ul-Moiz Khawaja
Recomendados
Abstract data types
Abstract data types
Poojith Chowdhary
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
St Mary's College,Thrissur,Kerala
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt) intro to data structure part 2
Self-Employed
Abstract Data Types
Abstract Data Types
karthikeyanC40
Introduction to data structure
Introduction to data structure
Vivek Kumar Sinha
Slide 1.-datastructure
Slide 1.-datastructure
Minhaz Leo
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
Kathirvel Ayyaswamy
Algo>Abstract data type
Algo>Abstract data type
Ain-ul-Moiz Khawaja
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
Malikireddy Bramhananda Reddy
Elementary data structure
Elementary data structure
Biswajit Mandal
Data structures
Data structures
Lovely Professional University
Lecture 01 Intro to DSA
Lecture 01 Intro to DSA
Nurjahan Nipa
Data structures Basics
Data structures Basics
DurgaDeviCbit
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
Data Structures (CS8391)
Data Structures (CS8391)
Elavarasi K
Data structures (introduction)
Data structures (introduction)
Arvind Devaraj
Data structure lecture 2
Data structure lecture 2
Abbott
Abstract data types
Abstract data types
Hoang Nguyen
Data Structures
Data Structures
Dr.Umadevi V
Data structure and its types
Data structure and its types
Navtar Sidhu Brar
Data Structure and Algorithms
Data Structure and Algorithms
iqbalphy1
Ds chapter 2
Ds chapter 2
Prof .Pragati Khade
Introduction to Data Structure
Introduction to Data Structure
Prof Ansari
Data structure power point presentation
Data structure power point presentation
Anil Kumar Prajapati
Lecture 07 Data Structures - Basic Sorting
Lecture 07 Data Structures - Basic Sorting
Haitham El-Ghareeb
DATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGE
shubhamrohiwal6
Lecture-05-DSA
Lecture-05-DSA
Haitham El-Ghareeb
Data Structure
Data Structure
sheraz1
03 data abstraction
03 data abstraction
Opas Kaewtai
Abstract Data Types
Abstract Data Types
Reggie Niccolo Santos
Más contenido relacionado
La actualidad más candente
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
Malikireddy Bramhananda Reddy
Elementary data structure
Elementary data structure
Biswajit Mandal
Data structures
Data structures
Lovely Professional University
Lecture 01 Intro to DSA
Lecture 01 Intro to DSA
Nurjahan Nipa
Data structures Basics
Data structures Basics
DurgaDeviCbit
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
Data Structures (CS8391)
Data Structures (CS8391)
Elavarasi K
Data structures (introduction)
Data structures (introduction)
Arvind Devaraj
Data structure lecture 2
Data structure lecture 2
Abbott
Abstract data types
Abstract data types
Hoang Nguyen
Data Structures
Data Structures
Dr.Umadevi V
Data structure and its types
Data structure and its types
Navtar Sidhu Brar
Data Structure and Algorithms
Data Structure and Algorithms
iqbalphy1
Ds chapter 2
Ds chapter 2
Prof .Pragati Khade
Introduction to Data Structure
Introduction to Data Structure
Prof Ansari
Data structure power point presentation
Data structure power point presentation
Anil Kumar Prajapati
Lecture 07 Data Structures - Basic Sorting
Lecture 07 Data Structures - Basic Sorting
Haitham El-Ghareeb
DATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGE
shubhamrohiwal6
Lecture-05-DSA
Lecture-05-DSA
Haitham El-Ghareeb
Data Structure
Data Structure
sheraz1
La actualidad más candente
(20)
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
Elementary data structure
Elementary data structure
Data structures
Data structures
Lecture 01 Intro to DSA
Lecture 01 Intro to DSA
Data structures Basics
Data structures Basics
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Data Structures (CS8391)
Data Structures (CS8391)
Data structures (introduction)
Data structures (introduction)
Data structure lecture 2
Data structure lecture 2
Abstract data types
Abstract data types
Data Structures
Data Structures
Data structure and its types
Data structure and its types
Data Structure and Algorithms
Data Structure and Algorithms
Ds chapter 2
Ds chapter 2
Introduction to Data Structure
Introduction to Data Structure
Data structure power point presentation
Data structure power point presentation
Lecture 07 Data Structures - Basic Sorting
Lecture 07 Data Structures - Basic Sorting
DATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGE
Lecture-05-DSA
Lecture-05-DSA
Data Structure
Data Structure
Destacado
03 data abstraction
03 data abstraction
Opas Kaewtai
Abstract Data Types
Abstract Data Types
Reggie Niccolo Santos
Slide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schema
Visakh V
Introduction to Data Abstraction
Introduction to Data Abstraction
Dennis Gajo
2CPP14 - Abstraction
2CPP14 - Abstraction
Michael Heron
บทที่ 2 สถาปัตยกรรม
บทที่ 2 สถาปัตยกรรม
PrinceStorm Nueng
Preparation Data Structures 03 abstract data_types
Preparation Data Structures 03 abstract data_types
Andres Mendez-Vazquez
Degrees of data abstraction
Degrees of data abstraction
Mary May Porto
Modular Architectures: What they are why do they matter now.
Modular Architectures: What they are why do they matter now.
Param Rengaiah
New coke
New coke
Vinay Kumar
Fddi
Fddi
Anuj Gupta
Product Architecture
Product Architecture
joems_angel2000
Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++
Liju Thomas
11 abstract data types
11 abstract data types
jigeno
Data dictionary
Data dictionary
Surbhi Panhalkar
Destacado
(15)
03 data abstraction
03 data abstraction
Abstract Data Types
Abstract Data Types
Slide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schema
Introduction to Data Abstraction
Introduction to Data Abstraction
2CPP14 - Abstraction
2CPP14 - Abstraction
บทที่ 2 สถาปัตยกรรม
บทที่ 2 สถาปัตยกรรม
Preparation Data Structures 03 abstract data_types
Preparation Data Structures 03 abstract data_types
Degrees of data abstraction
Degrees of data abstraction
Modular Architectures: What they are why do they matter now.
Modular Architectures: What they are why do they matter now.
New coke
New coke
Fddi
Fddi
Product Architecture
Product Architecture
Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++
11 abstract data types
11 abstract data types
Data dictionary
Data dictionary
Similar a Data abstraction the walls
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.ppt
BlackSeraph
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.ppt
MeenakshiPatel13
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
AntareepMajumder
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptx
sabithabanu83
4-OOPS.pptx
4-OOPS.pptx
SatyamMishra237306
data structure
data structure
hashim102
Abstract data types
Abstract data types
Harry Potter
Abstract data types
Abstract data types
Tony Nguyen
Abstract data types
Abstract data types
Luis Goldster
Abstract data types
Abstract data types
Fraboni Ec
Abstract data types
Abstract data types
James Wong
Abstract data types
Abstract data types
Young Alista
U nit i data structure-converted
U nit i data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
ch11-1.ppt
ch11-1.ppt
KarthiKeyan326587
dsa.ppt
dsa.ppt
ssuser1f953d
dsa.ppt
dsa.ppt
ssuser1f953d
dsa (1).ppt
dsa (1).ppt
ssuser1f953d
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
Nimmi Weeraddana
Lec3
Lec3
Ibrahim El-Torbany
Session 15 - Collections - Array List
Session 15 - Collections - Array List
PawanMM
Similar a Data abstraction the walls
(20)
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.ppt
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptx
4-OOPS.pptx
4-OOPS.pptx
data structure
data structure
Abstract data types
Abstract data types
Abstract data types
Abstract data types
Abstract data types
Abstract data types
Abstract data types
Abstract data types
Abstract data types
Abstract data types
Abstract data types
Abstract data types
U nit i data structure-converted
U nit i data structure-converted
ch11-1.ppt
ch11-1.ppt
dsa.ppt
dsa.ppt
dsa.ppt
dsa.ppt
dsa (1).ppt
dsa (1).ppt
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
Lec3
Lec3
Session 15 - Collections - Array List
Session 15 - Collections - Array List
Más de Hoang Nguyen
Rest api to integrate with your site
Rest api to integrate with your site
Hoang Nguyen
How to build a rest api
How to build a rest api
Hoang Nguyen
Api crash
Api crash
Hoang Nguyen
Smm and caching
Smm and caching
Hoang Nguyen
Optimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessors
Hoang Nguyen
How analysis services caching works
How analysis services caching works
Hoang Nguyen
Hardware managed cache
Hardware managed cache
Hoang Nguyen
Directory based cache coherence
Directory based cache coherence
Hoang Nguyen
Cache recap
Cache recap
Hoang Nguyen
Python your new best friend
Python your new best friend
Hoang Nguyen
Python language data types
Python language data types
Hoang Nguyen
Python basics
Python basics
Hoang Nguyen
Programming for engineers in python
Programming for engineers in python
Hoang Nguyen
Learning python
Learning python
Hoang Nguyen
Extending burp with python
Extending burp with python
Hoang Nguyen
Cobol, lisp, and python
Cobol, lisp, and python
Hoang Nguyen
Object oriented programming using c++
Object oriented programming using c++
Hoang Nguyen
Object oriented analysis
Object oriented analysis
Hoang Nguyen
Object model
Object model
Hoang Nguyen
Data structures and algorithms
Data structures and algorithms
Hoang Nguyen
Más de Hoang Nguyen
(20)
Rest api to integrate with your site
Rest api to integrate with your site
How to build a rest api
How to build a rest api
Api crash
Api crash
Smm and caching
Smm and caching
Optimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessors
How analysis services caching works
How analysis services caching works
Hardware managed cache
Hardware managed cache
Directory based cache coherence
Directory based cache coherence
Cache recap
Cache recap
Python your new best friend
Python your new best friend
Python language data types
Python language data types
Python basics
Python basics
Programming for engineers in python
Programming for engineers in python
Learning python
Learning python
Extending burp with python
Extending burp with python
Cobol, lisp, and python
Cobol, lisp, and python
Object oriented programming using c++
Object oriented programming using c++
Object oriented analysis
Object oriented analysis
Object model
Object model
Data structures and algorithms
Data structures and algorithms
Último
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Drew Madelung
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
The Digital Insurer
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
debabhi2
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
UK Journal
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
apidays
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Maria Levchenko
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Michael W. Hawkins
Evaluating the top large language models.pdf
Evaluating the top large language models.pdf
ChristopherTHyatt
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
lior mazor
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
naman860154
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
hans926745
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
hans926745
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
The Digital Insurer
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Anna Loughnan Colquhoun
Último
(20)
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Evaluating the top large language models.pdf
Evaluating the top large language models.pdf
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Data abstraction the walls
1.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-1 Abstract Data Types • Modularity – Keeps the complexity of a large program manageable by systematically controlling the interaction of its components – Isolates errors
2.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-2 Abstract Data Types • Modularity (Continued) – Eliminates redundancies – A modular program is • Easier to write • Easier to read • Easier to modify
3.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-3 Abstract Data Types • Procedural abstraction – Separates the purpose and use of a module from its implementation – A module’s specifications should • Detail how the module behaves • Identify details that can be hidden within the module
4.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-4 Abstract Data Types • Information hiding – Hides certain implementation details within a module – Makes these details inaccessible from outside the module
5.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-5 Abstract Data Types Figure 3.1 Isolated tasks: the implementation of task T does not affect task Q
6.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-6 Abstract Data Types • The isolation of modules is not total – Functions’ specifications, or contracts, govern how they interact with each other Figure 3.2 A slit in the wall
7.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-7 Abstract Data Types • Typical operations on data – Add data to a data collection – Remove data from a data collection – Ask questions about the data in a data collection
8.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-8 Abstract Data Types • Data abstraction – Asks you to think what you can do to a collection of data independently of how you do it – Allows you to develop each data structure in relative isolation from the rest of the solution – A natural extension of procedural abstraction
9.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-9 Abstract Data Types • Abstract data type (ADT) – An ADT is composed of • A collection of data • A set of operations on that data – Specifications of an ADT indicate • What the ADT operations do, not how to implement them – Implementation of an ADT • Includes choosing a particular data structure
10.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-10 Abstract Data Types Figure 3.4 A wall of ADT operations isolates a data structure from the program that uses it
11.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-11 The ADT List • Except for the first and last items, each item has a unique predecessor and a unique successor • Head or front do not have a predecessor • Tail or end do not have a successor
12.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-12 The ADT List • Items are referenced by their position within the list • Specifications of the ADT operations – Define the contract for the ADT list – Do not specify how to store the list or how to perform the operations • ADT operations can be used in an application without the knowledge of how the operations will be implemented
13.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-13 The ADT List • ADT List operations – Create an empty list – Determine whether a list is empty – Determine the number of items in a list – Add an item at a given position in the list – Remove the item at a given position in the list – Remove all the items from the list – Retrieve (get) item at a given position in the list
14.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-14 The ADT List • The ADT sorted list – Maintains items in sorted order – Inserts and deletes items by their values, not their positions
15.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-15 The ADT List Figure 3.7 The wall between displayList and the implementation of the ADT list
16.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-16 Designing an ADT • The design of an ADT should evolve naturally during the problem-solving process • Questions to ask when designing an ADT – What data does a problem require? – What operations does a problem require?
17.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-17 Designing an ADT • For complex abstract data types, the behavior of the operations must be specified using axioms – Axiom: A mathematical rule – Ex. : (aList.createList()).size() = 0
18.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-18 Implementing ADTs • Choosing the data structure to represent the ADT’s data is a part of implementation – Choice of a data structure depends on • Details of the ADT’s operations • Context in which the operations will be used
19.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-19 Implementing ADTs • Implementation details should be hidden behind a wall of ADT operations – A program would only be able to access the data structure using the ADT operations
20.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-20 Implementing ADTs Figure 3.8 ADT operations provide access to a data structure
21.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-21 Implementing ADTs Figure 3.9 Violating the wall of ADT operations
22.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-22 C++ Classes • Encapsulation combines an ADT’s data with its operations to form an object – An object is an instance of a class – A class contains data members and member functions • By default, all members in a class are private
23.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-23 C++ Classes • Each class definition is placed in a header file – Classname.h • The implementation of a class’s member functions are placed in an implementation file – Classname.cpp
24.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-24 C++ Classes Figure 3.10 An object’s data and methods are encapsulated
25.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-25 Class Constructors and Destructors • Constructors – Create and initialize new instances of a class – Have the same name as the class – Have no return type, not even void
26.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-26 Class Constructors and Destructors • A class can have several constructors – A default constructor has no arguments – Initializers can set data members to initial values – The compiler will generate a default constructor if one is omitted
27.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-27 Class Constructors and Destructors • The implementation of a constructor (or any member function) is qualified with the scope resolution operator :: Sphere::Sphere(double initialRadius) : theRadius(initialRadius)
28.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-28 Class Constructors and Destructors • Destructors – Destroy an instance of an object when the object’s lifetime ends • Each class has one destructor – For many classes, the destructor can be omitted – The compiler will generate a default constructor if one is omitted
29.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-29 Inheritance in C++ • A derived class or subclass inherits any of the publicly defined functions or data members of a base class or superclass
30.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-30 Inheritance in C++ • An instance of a derived class can invoke public methods of the base class: #include “Sphere.h” enum Color {RED, BLUE, GREEN, YELLOW} class ColoredSphere: public Sphere { public: … Color getColor() const; …
31.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-31 C++ Namespaces • A mechanism for logically grouping declarations and definitions into a common declarative region
32.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-32 C++ Namespaces • The contents of the namespace can be accessed by code inside or outside the namespace – Use the scope resolution operator to access elements from outside the namespace – Alternatively, the using declaration allows the names of the elements to be used directly
33.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-33 C++ Namespaces • Creating a namespace namespace smallNamespace { int count = 0; void abc(); } //end smallNamespace • Using a namespace using namespace smallNamespace; count +=1; abc();
34.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-34 C++ Namespaces • Items declared in the C++ Standard Library are declared in the std namespace • C++ include files for several functions are in the std namespace – To include input and output functions from the C++ library, write include <iostream> using namespace std;
35.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-35 An Array-Based ADT List • A list’s items are stored in an array items • Both an array and a list identify their items by number
36.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-36 An Array-Based ADT List • A list’s kth item will be stored in items[k- 1] Figure 3.11 An array-based implementation of the ADT list
37.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-37 C++ Exceptions • Exception – A mechanism for handling an error during execution – A function indicates that an error has occurred by throwing an exception – The code that deals with the exception is said to catch or handle it
38.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-38 C++ Exceptions • Throwing exceptions – A throw statement is used to throw an exception throw ExceptionClass (stringArgument);
39.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-39 C++ Exceptions • try block – A statement that might throw an exception is placed within a try block – Syntax try { statement(s); } // end try
40.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-40 C++ Exceptions • catch block – Used to catch an exception and deal with the error condition – Syntax catch (exceptionClass identifier) { statement(s); } // end catch
41.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-41 C++ Exceptions • A programmer-define ListException class #include <exception> #include <string> using namespace std; class ListException: public exception { public: ListException (const string & message = “”) : exception(message.c_str()) {} }; // end ListException
42.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-42 Summary • Data abstraction controls the interaction between a program and its data structures • Abstract data type (ADT): a set of data- management operations together with the data values upon which they operate • Mathematical study of ADTs uses axioms to specify the behavior of ADT operations • An ADT should be fully defined before any implementation decisions
43.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-43 Summary • Hide an ADT’s implementation by defining the ADT as a C++ class • An object encapsulates both data and operations • A class contains at least one constructor and a destructor • The compiler generates default constructor and destructor if none are provided
44.
© 2005 Pearson
Addison-Wesley. All rights reserved 3-44 Summary • Members of a class are private by default – Data members are typically private – Public functions can be provided to access them • Define and implement a class within header and implementation files • Namespace: a mechanism to group classes, functions, variables, types, and constants • Use exception handling to throw, catch, and handle errors during program execution
Descargar ahora