SlideShare a Scribd company logo
1 of 8
+




    Lecture 1 – Introduction to
    C++ Classes (Part 4)
    TTTK1924 – Program Design and Problem
    Solving
+
    Part 4
    Data Abstraction and Classes
+
    Data Abstraction


     Separationof data logical properties from
     data implementation details
     Users are given the abstract representation
     of data, while the implementation details are
     hidden
+
    Abstract Data Types (ADT)

     Structured data types that apply data abstraction
     concept – data types that separate the logical
     properties from the implementation details

     An ADT   usually has 3 things:
      Type name (name of ADT)
      Domain – set of values belonging to the ADT
      Set of operations – operations that can be done to the
       values in ADT (can be used by others)
+
    Abstract Data Type - Examples

    An ADT that handles time:

       Type name : clockType

       Domain : the values of a clock in the form of
        hours, minutes, and seconds

       Set of Operations :
           Set the time
           Returns the time
           Increment the time by one second
           Increment the time by one minute
           Increment the time by one hour
           Compare the two times to see whether they are equal
+
    Abstract Data Type - Examples
    An ADT that handles a list of items:

       Type name : listType

       Domain : a collection of items, for example an array of 100
        integers

       Set of Operations :
           Check to see whether the list is empty
           Check to see whether the list is full
           Search the list for a given item
           Delete an item from the list
           Insert an item into the list
           Sort the list
           Destroy the list
           Print the items of the list
+
    Implementation of ADT

     Obviously,classes   class listType {
                          public:
     can be used to         bool isEmptyList() const;
     define an ADT          bool is FullList() const;
                            int search( int item) const;
                            void insert(int item);
                            void remove(int item);
                            void destroyList();
                            void printList() const;
                            listType();

                          private:
                             int list[100];
                             int length;
                          };
+
    References:

       D.S. Malik (2012). C++ Programming: Program Design
        Including Data Structures (5th ed), Thomson Course
        Technology.
           Chapter 11 – Classes and Data Abstraction

More Related Content

What's hot

Array in c language
Array in c languageArray in c language
Array in c languageumesh patil
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : ArraysGagan Deep
 
Presentation on basics of python
Presentation on basics of pythonPresentation on basics of python
Presentation on basics of pythonNanditaDutta4
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array pptsandhya yadav
 
Ds
DsDs
DsAcad
 
PyData NYC whatsnew NumPy-SciPy 2019
PyData NYC whatsnew NumPy-SciPy 2019PyData NYC whatsnew NumPy-SciPy 2019
PyData NYC whatsnew NumPy-SciPy 2019Ralf Gommers
 
Data Analysis in Python-NumPy
Data Analysis in Python-NumPyData Analysis in Python-NumPy
Data Analysis in Python-NumPyDevashish Kumar
 
Python advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithmPython advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithmJohn(Qiang) Zhang
 
Python advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structuresPython advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structuresJohn(Qiang) Zhang
 

What's hot (20)

Data Analysis packages
Data Analysis packagesData Analysis packages
Data Analysis packages
 
Array in c
Array in cArray in c
Array in c
 
Array in C
Array in CArray in C
Array in C
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Array in c
Array in cArray in c
Array in c
 
Array in-c
Array in-cArray in-c
Array in-c
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
Presentation on basics of python
Presentation on basics of pythonPresentation on basics of python
Presentation on basics of python
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
R Cheat Sheet
R Cheat SheetR Cheat Sheet
R Cheat Sheet
 
Ds
DsDs
Ds
 
Numpy
NumpyNumpy
Numpy
 
Mutable data types in python
Mutable data types in pythonMutable data types in python
Mutable data types in python
 
PyData NYC whatsnew NumPy-SciPy 2019
PyData NYC whatsnew NumPy-SciPy 2019PyData NYC whatsnew NumPy-SciPy 2019
PyData NYC whatsnew NumPy-SciPy 2019
 
Data Analysis in Python-NumPy
Data Analysis in Python-NumPyData Analysis in Python-NumPy
Data Analysis in Python-NumPy
 
Python advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithmPython advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithm
 
Stack Data structure
Stack Data structureStack Data structure
Stack Data structure
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Python advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structuresPython advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structures
 

Viewers also liked

c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programAAKASH KUMAR
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language Mohamed Loey
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.pptTareq Hasan
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 

Viewers also liked (9)

Lecture1 classes1
Lecture1 classes1Lecture1 classes1
Lecture1 classes1
 
c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ program
 
Intro to C++ - language
Intro to C++ - languageIntro to C++ - language
Intro to C++ - language
 
C++ programming
C++ programmingC++ programming
C++ programming
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 

Similar to Lecture1 classes4

Object oriented programming using c++
Object oriented programming using c++Object oriented programming using c++
Object oriented programming using c++Hoang Nguyen
 
5. c sharp language overview part ii
5. c sharp language overview   part ii5. c sharp language overview   part ii
5. c sharp language overview part iiSvetlin Nakov
 
The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.3 book - Part 13 of 88The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.3 book - Part 13 of 88Mahmoud Samir Fayed
 
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptTopic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptBlackSeraph
 
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptTopic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptMeenakshiPatel13
 
16 Linear data structures
16 Linear data structures16 Linear data structures
16 Linear data structuresmaznabili
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharpsarfarazali
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#singhadarsh
 
The Ring programming language version 1.5.2 book - Part 21 of 181
The Ring programming language version 1.5.2 book - Part 21 of 181The Ring programming language version 1.5.2 book - Part 21 of 181
The Ring programming language version 1.5.2 book - Part 21 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 24 of 189
The Ring programming language version 1.6 book - Part 24 of 189The Ring programming language version 1.6 book - Part 24 of 189
The Ring programming language version 1.6 book - Part 24 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184Mahmoud Samir Fayed
 
C# Language Overview Part II
C# Language Overview Part IIC# Language Overview Part II
C# Language Overview Part IIDoncho Minkov
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Barry DeCicco
 
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxchapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxAmrutaNavale2
 
C# Summer course - Lecture 3
C# Summer course - Lecture 3C# Summer course - Lecture 3
C# Summer course - Lecture 3mohamedsamyali
 

Similar to Lecture1 classes4 (20)

Object oriented programming using c++
Object oriented programming using c++Object oriented programming using c++
Object oriented programming using c++
 
5. c sharp language overview part ii
5. c sharp language overview   part ii5. c sharp language overview   part ii
5. c sharp language overview part ii
 
C# overview part 2
C# overview part 2C# overview part 2
C# overview part 2
 
The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.3 book - Part 13 of 88The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.3 book - Part 13 of 88
 
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptTopic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.ppt
 
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptTopic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.ppt
 
Python for beginners
Python for beginnersPython for beginners
Python for beginners
 
16 Linear data structures
16 Linear data structures16 Linear data structures
16 Linear data structures
 
List,Stacks and Queues.pptx
List,Stacks and Queues.pptxList,Stacks and Queues.pptx
List,Stacks and Queues.pptx
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharp
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
The Ring programming language version 1.5.2 book - Part 21 of 181
The Ring programming language version 1.5.2 book - Part 21 of 181The Ring programming language version 1.5.2 book - Part 21 of 181
The Ring programming language version 1.5.2 book - Part 21 of 181
 
The Ring programming language version 1.6 book - Part 24 of 189
The Ring programming language version 1.6 book - Part 24 of 189The Ring programming language version 1.6 book - Part 24 of 189
The Ring programming language version 1.6 book - Part 24 of 189
 
The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184
 
C# Language Overview Part II
C# Language Overview Part IIC# Language Overview Part II
C# Language Overview Part II
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06
 
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxchapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
 
C# Summer course - Lecture 3
C# Summer course - Lecture 3C# Summer course - Lecture 3
C# Summer course - Lecture 3
 

Lecture1 classes4

  • 1. + Lecture 1 – Introduction to C++ Classes (Part 4) TTTK1924 – Program Design and Problem Solving
  • 2. + Part 4 Data Abstraction and Classes
  • 3. + Data Abstraction  Separationof data logical properties from data implementation details  Users are given the abstract representation of data, while the implementation details are hidden
  • 4. + Abstract Data Types (ADT)  Structured data types that apply data abstraction concept – data types that separate the logical properties from the implementation details  An ADT usually has 3 things:  Type name (name of ADT)  Domain – set of values belonging to the ADT  Set of operations – operations that can be done to the values in ADT (can be used by others)
  • 5. + Abstract Data Type - Examples An ADT that handles time:  Type name : clockType  Domain : the values of a clock in the form of hours, minutes, and seconds  Set of Operations :  Set the time  Returns the time  Increment the time by one second  Increment the time by one minute  Increment the time by one hour  Compare the two times to see whether they are equal
  • 6. + Abstract Data Type - Examples An ADT that handles a list of items:  Type name : listType  Domain : a collection of items, for example an array of 100 integers  Set of Operations :  Check to see whether the list is empty  Check to see whether the list is full  Search the list for a given item  Delete an item from the list  Insert an item into the list  Sort the list  Destroy the list  Print the items of the list
  • 7. + Implementation of ADT  Obviously,classes class listType { public: can be used to bool isEmptyList() const; define an ADT bool is FullList() const; int search( int item) const; void insert(int item); void remove(int item); void destroyList(); void printList() const; listType(); private: int list[100]; int length; };
  • 8. + References:  D.S. Malik (2012). C++ Programming: Program Design Including Data Structures (5th ed), Thomson Course Technology.  Chapter 11 – Classes and Data Abstraction