SlideShare a Scribd company logo
ICS 313 - Fundamentals of Programming Languages 1
11. Abstract Data Types
11.1 The Concept of Abstraction
The concept of abstraction is fundamental in
programming
Nearly all programming languages support
process abstraction with subprograms
Nearly all programming languages designed since
1980 have supported data abstraction with some
kind of module
ICS 313 - Fundamentals of Programming Languages 2
11.2 Encapsulation
Original motivation:
Large programs have two special needs:
Some means of organization, other than simply division into subprograms
Some means of partial compilation (compilation units that are smaller than the whole program)
Obvious solution: a grouping of subprograms that are logically
related into a unit that can be separately compiled (compilation units)
These are called encapsulations
Examples of Encapsulation Mechanisms
Nested subprograms in some ALGOL-like languages (e.g., Pascal)
FORTRAN 77 and C - Files containing one or more subprograms can
be independently compiled
FORTRAN 90 and Ada - separately compilable modules
11.3 Introduction to Data Abstraction
An abstract data type is a user-defined data
type that satisfies the following two conditions:
1. The representation of and operations on objects of the
type are defined in a single syntactic unit; also, other
units can create objects of the type
2. The representation of objects of the type is hidden
from the program units that use these objects, so the only
operations possible are those provided in the type's
definition.
ICS 313 - Fundamentals of Programming Languages 3
11.3 Introduction to Data Abstraction (continued)
Advantage of Restriction 1:
Same as those for encapsulation: program organization, modifiability
(everything associated with a data structure is together), and separate
compilation
Advantage of Restriction 2:
Reliability--by hiding the data representations, user code cannot
directly access objects of the type. User code cannot depend on the
representation, allowing the representation to be changed without
affecting user code
Built-in types are abstract data types
e.g. int type in Java
The representation is hidden
Operations are all built-in
User programs can define objects of int type
User-defined abstract data types must have the same characteristics
as built-in abstract data types
11.4 Design Issues
Language Requirements to support abstract data types:
A syntactic unit in which to encapsulate the type definition.
A method of making type names and subprogram headers
visible to clients, while hiding actual definitions.
Some primitive operations must be built into the language
processor (usually just assignment and comparisons for
equality and inequality)
Some operations are commonly needed, but must be defined by the type designer
- e.g., iterators, constructors, destructors
Language Design Issues:
Encapsulate a single type, or something more?
What types can be abstract?
Can abstract types be parameterized?
What access controls are provided?
ICS 313 - Fundamentals of Programming Languages 4
11.5 Language Examples
Simula 67
Provided encapsulation, but no information hiding
Ada
The encapsulation construct is the package
Packages usually have two parts:
Specification package (the interface)
Body package (implementation of the entities named in the specification
Information Hiding
Hidden types are named in the spec package, as in:
type NODE_TYPE is private;
11.5 Language Examples (continued)
Representation of an exported hidden type is specified in a special invisible (to
clients) part of the spec package (the private clause), as in:
package … is
type NODE_TYPE is private;
…
private
type NODE_TYPE is
record
…
end record;
…
A spec package can also define unhidden types simply by providing the
representation outside a private clause
The reasons for the two-part type definition are:
The compiler must be able to see the representation after seeing only the spec
package (the compiler can see the private clause)
Clients must see the type name, but not the representation (clients cannot see the
private clause)
ICS 313 - Fundamentals of Programming Languages 5
11.5 Language Examples (continued)
Private types have built-in operations for assignment
and comparison with = and /=
Limited private types have no built-in operations
---> SHOW specification and body packages
(pp. 443-444) and the procedure that uses
them (p. 445)
11.5 Language Examples (continued)
C++
Based on C struct type and Simula 67 classes
The class is the encapsulation device
All of the class instances of a class share a single copy of the member
functions
Each instance of a class has its own copy of the class data members
Instances can be static, stack dynamic, or heap dynamic
Information Hiding:
Private clause for hidden entities
Public clause for interface entities
Protected clause - for inheritance (see Ch. 12)
Constructors:
Functions to initialize the data members of instances (they DO NOT create the objects)
May also allocate storage if part of the object is heap-dynamic
Can include parameters to provide parameterization of the objects
Implicitly called when an instance is created
Can be explicitly called
Name is the same as the class name
ICS 313 - Fundamentals of Programming Languages 6
11.5 Language Examples (continued)
C++ (continued)
Destructors
Functions to cleanup after an instance is destroyed; usually just to reclaim heap
storage
Implicitly called when the object’s lifetime ends
Can be explicitly called
Name is the class name, preceded by a tilda (~)
See class definition for stack (p. 447) and the example program
that uses it (p. 448)
Friend functions or classes - to provide access to private
members to some unrelated units or functions (NECESSARY in
C++)
Evaluation of C++ Support for Abstract Data Types
Classes are similar to Ada packages for providing abstract data
types
Difference: packages are encapsulations, whereas classes are
types
11.5 Language Examples (continued)
A Related Language: Java
Similar to C++, except:
All user-defined types are classes
All objects are allocated from the heap and accessed through reference
variables
Individual entities in classes have access control modifiers (private or
public), rather than clauses
Java has a second scoping mechanism, package scope, which can be
used in place of friends
All entities in all classes in a package that do not have access control
modifiers are visible throughout the package
See Java class definition for stacks (p. 449-450) and the
class that uses it (p. 450)
ICS 313 - Fundamentals of Programming Languages 7
11.6 Parameterized Abstract Dats Types
Ada Generic Packages
Make the stack type more flexible by making the element type and the size of the
stack generic
See GENERIC_STACK package (p. 451)
package INT_STACK is new GENERIC_STACK(100, INTEGER);
package FLOAT_STACK is new GENERIC_STACK(500, FLOAT);
C++ Templated Classes
Classes can be somewhat generic by writing parameterized constructor functions
e.g.
stack (int size) {
stk_ptr = new int [size];
max_len = size - 1;
top = -1;
}
stack (100) stk;
The stack element type can be parameterized by making the class a templated
class
See the templated class stack (p. 452-453)
Java does not support generic abstract data types

More Related Content

PPTX
Abstraction file
Hoang Nguyen
 
PPT
Abstract data types
Hoang Nguyen
 
PPT
C++ classes
imhammadali
 
PPTX
Vb ch 3-object-oriented_fundamentals_in_vb.net
bantamlak dejene
 
PPT
Classes and data abstraction
Hoang Nguyen
 
PDF
Structures in c++
Swarup Kumar Boro
 
PPTX
Chapter 13 introduction to classes
rsnyder3601
 
DOC
My c++
snathick
 
Abstraction file
Hoang Nguyen
 
Abstract data types
Hoang Nguyen
 
C++ classes
imhammadali
 
Vb ch 3-object-oriented_fundamentals_in_vb.net
bantamlak dejene
 
Classes and data abstraction
Hoang Nguyen
 
Structures in c++
Swarup Kumar Boro
 
Chapter 13 introduction to classes
rsnyder3601
 
My c++
snathick
 

What's hot (16)

DOC
Question bank unit i
Rasi Manivannan
 
PDF
Introduction to database-ER Model
Ajit Nayak
 
PDF
Object oriented concepts
Pranali Chaudhari
 
DOCX
Vhdl
vishnu murthy
 
PPT
Object oriented programming using c++
Hoang Nguyen
 
PDF
C++ Object oriented concepts & programming
nirajmandaliya
 
PPTX
Java Data Types
Spotle.ai
 
PPT
Data abstraction and object orientation
Hoang Nguyen
 
PDF
Classes and objects
Nilesh Dalvi
 
PDF
Datatype
baran19901990
 
DOCX
Primitive data types
bad_zurbic
 
PDF
Introduction java programming
Nanthini Kempaiyan
 
PPTX
Chapter 04 object oriented programming
Praveen M Jigajinni
 
PDF
Python Programming - XII. File Processing
Ranel Padon
 
PDF
Introduction on Data Structures
Nanthini Kempaiyan
 
Question bank unit i
Rasi Manivannan
 
Introduction to database-ER Model
Ajit Nayak
 
Object oriented concepts
Pranali Chaudhari
 
Object oriented programming using c++
Hoang Nguyen
 
C++ Object oriented concepts & programming
nirajmandaliya
 
Java Data Types
Spotle.ai
 
Data abstraction and object orientation
Hoang Nguyen
 
Classes and objects
Nilesh Dalvi
 
Datatype
baran19901990
 
Primitive data types
bad_zurbic
 
Introduction java programming
Nanthini Kempaiyan
 
Chapter 04 object oriented programming
Praveen M Jigajinni
 
Python Programming - XII. File Processing
Ranel Padon
 
Introduction on Data Structures
Nanthini Kempaiyan
 
Ad

Viewers also liked (20)

PPT
Algo>Abstract data type
Ain-ul-Moiz Khawaja
 
PPT
Abstract data types
Luis Goldster
 
PPT
Abstract data types
Poojith Chowdhary
 
PDF
Abstract Data Types
Reggie Niccolo Santos
 
PPTX
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Hassan Ahmed
 
PPTX
Data structures and algorithms
Harry Potter
 
PDF
Array linear data_structure_2 (1)
eShikshak
 
PDF
Preparation Data Structures 03 abstract data_types
Andres Mendez-Vazquez
 
PPT
Data abstraction the walls
Hoang Nguyen
 
PPT
Abstract data types
Tony Nguyen
 
PDF
Unit i data structure FYCS MUMBAI UNIVERSITY SEM II
ajay pashankar
 
PDF
03 data abstraction
Opas Kaewtai
 
PPTX
Ch7 implementation
software-engineering-book
 
PPT
Arrays Data Structure
student
 
PPTX
Slide 3 data abstraction & 3 schema
Visakh V
 
PPT
Unit 2 Principles of Programming Languages
Vasavi College of Engg
 
PPTX
Introduction to Java
Ashita Agrawal
 
PDF
D.SCBL-NEW
Thomas Godfrey
 
PDF
iLive 2011 - Pjotr Tsvetkov: How to start an affiliate program?
iLive Conference
 
PPTX
The seen and unseen about metals
Maria Vincent
 
Algo>Abstract data type
Ain-ul-Moiz Khawaja
 
Abstract data types
Luis Goldster
 
Abstract data types
Poojith Chowdhary
 
Abstract Data Types
Reggie Niccolo Santos
 
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Hassan Ahmed
 
Data structures and algorithms
Harry Potter
 
Array linear data_structure_2 (1)
eShikshak
 
Preparation Data Structures 03 abstract data_types
Andres Mendez-Vazquez
 
Data abstraction the walls
Hoang Nguyen
 
Abstract data types
Tony Nguyen
 
Unit i data structure FYCS MUMBAI UNIVERSITY SEM II
ajay pashankar
 
03 data abstraction
Opas Kaewtai
 
Ch7 implementation
software-engineering-book
 
Arrays Data Structure
student
 
Slide 3 data abstraction & 3 schema
Visakh V
 
Unit 2 Principles of Programming Languages
Vasavi College of Engg
 
Introduction to Java
Ashita Agrawal
 
D.SCBL-NEW
Thomas Godfrey
 
iLive 2011 - Pjotr Tsvetkov: How to start an affiliate program?
iLive Conference
 
The seen and unseen about metals
Maria Vincent
 
Ad

Similar to 11 abstract data types (20)

PPT
object oriented programming presentation.ppt
norhasiahakhir1
 
PPT
ch11-1.ppt
KarthiKeyan326587
 
PPT
Abstract data types
Harry Potter
 
PPT
Abstract data types
Fraboni Ec
 
PPT
Abstract data types
Young Alista
 
PPT
Abstract data types
James Wong
 
PPT
core java
Vinodh Kumar
 
PPT
pl10ch6_datatypesprinciplesof programing.ppt
vimalgaur7
 
PPT
6 data types
Munawar Ahmed
 
PPT
5 Names, bindings,Typechecking and Scopes
Munawar Ahmed
 
PPT
Chapter10_Data_Abstraction_and_Object_Orientation_4e.ppt
techtrainer11
 
PDF
Notes of programming
Bilal Maqbool ツ
 
PDF
Java chapter 3
Mukesh Tekwani
 
PPTX
data abstraction ,encapsulation,A.D.T
kapil10197
 
PPT
pl12ch6.ppt
BrandonGarcia294013
 
PPTX
Java Programming - UNIT - 1, Basics OOPS, Differences
PradeepT42
 
PPT
Theory of programming language chapter 6
memonrizwan053
 
PDF
Lab3cth
Muhammad Yusfa
 
PPTX
DS 2024 Lecturde dcdcdcdcdcdcd3 & 4.pptx
BilalAshfaqAhmed2
 
PDF
6 data types
jigeno
 
object oriented programming presentation.ppt
norhasiahakhir1
 
ch11-1.ppt
KarthiKeyan326587
 
Abstract data types
Harry Potter
 
Abstract data types
Fraboni Ec
 
Abstract data types
Young Alista
 
Abstract data types
James Wong
 
core java
Vinodh Kumar
 
pl10ch6_datatypesprinciplesof programing.ppt
vimalgaur7
 
6 data types
Munawar Ahmed
 
5 Names, bindings,Typechecking and Scopes
Munawar Ahmed
 
Chapter10_Data_Abstraction_and_Object_Orientation_4e.ppt
techtrainer11
 
Notes of programming
Bilal Maqbool ツ
 
Java chapter 3
Mukesh Tekwani
 
data abstraction ,encapsulation,A.D.T
kapil10197
 
pl12ch6.ppt
BrandonGarcia294013
 
Java Programming - UNIT - 1, Basics OOPS, Differences
PradeepT42
 
Theory of programming language chapter 6
memonrizwan053
 
DS 2024 Lecturde dcdcdcdcdcdcd3 & 4.pptx
BilalAshfaqAhmed2
 
6 data types
jigeno
 

More from jigeno (19)

PDF
Access2007 part1
jigeno
 
PDF
Basic introduction to ms access
jigeno
 
PPSX
Bsit1
jigeno
 
PDF
16 logical programming
jigeno
 
PDF
15 functional programming
jigeno
 
PDF
15 functional programming
jigeno
 
PDF
14 exception handling
jigeno
 
PDF
13 concurrency
jigeno
 
PDF
12 object oriented programming
jigeno
 
PDF
9 subprograms
jigeno
 
PDF
8 statement-level control structure
jigeno
 
PDF
7 expressions and assignment statements
jigeno
 
PDF
5 names
jigeno
 
PDF
4 lexical and syntax analysis
jigeno
 
PDF
3 describing syntax and semantics
jigeno
 
PDF
2 evolution of the major programming languages
jigeno
 
PDF
1 preliminaries
jigeno
 
PDF
Access2007 m2
jigeno
 
PDF
Access2007 m1
jigeno
 
Access2007 part1
jigeno
 
Basic introduction to ms access
jigeno
 
Bsit1
jigeno
 
16 logical programming
jigeno
 
15 functional programming
jigeno
 
15 functional programming
jigeno
 
14 exception handling
jigeno
 
13 concurrency
jigeno
 
12 object oriented programming
jigeno
 
9 subprograms
jigeno
 
8 statement-level control structure
jigeno
 
7 expressions and assignment statements
jigeno
 
5 names
jigeno
 
4 lexical and syntax analysis
jigeno
 
3 describing syntax and semantics
jigeno
 
2 evolution of the major programming languages
jigeno
 
1 preliminaries
jigeno
 
Access2007 m2
jigeno
 
Access2007 m1
jigeno
 

Recently uploaded (20)

PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
Software Development Methodologies in 2025
KodekX
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Software Development Methodologies in 2025
KodekX
 

11 abstract data types

  • 1. ICS 313 - Fundamentals of Programming Languages 1 11. Abstract Data Types 11.1 The Concept of Abstraction The concept of abstraction is fundamental in programming Nearly all programming languages support process abstraction with subprograms Nearly all programming languages designed since 1980 have supported data abstraction with some kind of module
  • 2. ICS 313 - Fundamentals of Programming Languages 2 11.2 Encapsulation Original motivation: Large programs have two special needs: Some means of organization, other than simply division into subprograms Some means of partial compilation (compilation units that are smaller than the whole program) Obvious solution: a grouping of subprograms that are logically related into a unit that can be separately compiled (compilation units) These are called encapsulations Examples of Encapsulation Mechanisms Nested subprograms in some ALGOL-like languages (e.g., Pascal) FORTRAN 77 and C - Files containing one or more subprograms can be independently compiled FORTRAN 90 and Ada - separately compilable modules 11.3 Introduction to Data Abstraction An abstract data type is a user-defined data type that satisfies the following two conditions: 1. The representation of and operations on objects of the type are defined in a single syntactic unit; also, other units can create objects of the type 2. The representation of objects of the type is hidden from the program units that use these objects, so the only operations possible are those provided in the type's definition.
  • 3. ICS 313 - Fundamentals of Programming Languages 3 11.3 Introduction to Data Abstraction (continued) Advantage of Restriction 1: Same as those for encapsulation: program organization, modifiability (everything associated with a data structure is together), and separate compilation Advantage of Restriction 2: Reliability--by hiding the data representations, user code cannot directly access objects of the type. User code cannot depend on the representation, allowing the representation to be changed without affecting user code Built-in types are abstract data types e.g. int type in Java The representation is hidden Operations are all built-in User programs can define objects of int type User-defined abstract data types must have the same characteristics as built-in abstract data types 11.4 Design Issues Language Requirements to support abstract data types: A syntactic unit in which to encapsulate the type definition. A method of making type names and subprogram headers visible to clients, while hiding actual definitions. Some primitive operations must be built into the language processor (usually just assignment and comparisons for equality and inequality) Some operations are commonly needed, but must be defined by the type designer - e.g., iterators, constructors, destructors Language Design Issues: Encapsulate a single type, or something more? What types can be abstract? Can abstract types be parameterized? What access controls are provided?
  • 4. ICS 313 - Fundamentals of Programming Languages 4 11.5 Language Examples Simula 67 Provided encapsulation, but no information hiding Ada The encapsulation construct is the package Packages usually have two parts: Specification package (the interface) Body package (implementation of the entities named in the specification Information Hiding Hidden types are named in the spec package, as in: type NODE_TYPE is private; 11.5 Language Examples (continued) Representation of an exported hidden type is specified in a special invisible (to clients) part of the spec package (the private clause), as in: package … is type NODE_TYPE is private; … private type NODE_TYPE is record … end record; … A spec package can also define unhidden types simply by providing the representation outside a private clause The reasons for the two-part type definition are: The compiler must be able to see the representation after seeing only the spec package (the compiler can see the private clause) Clients must see the type name, but not the representation (clients cannot see the private clause)
  • 5. ICS 313 - Fundamentals of Programming Languages 5 11.5 Language Examples (continued) Private types have built-in operations for assignment and comparison with = and /= Limited private types have no built-in operations ---> SHOW specification and body packages (pp. 443-444) and the procedure that uses them (p. 445) 11.5 Language Examples (continued) C++ Based on C struct type and Simula 67 classes The class is the encapsulation device All of the class instances of a class share a single copy of the member functions Each instance of a class has its own copy of the class data members Instances can be static, stack dynamic, or heap dynamic Information Hiding: Private clause for hidden entities Public clause for interface entities Protected clause - for inheritance (see Ch. 12) Constructors: Functions to initialize the data members of instances (they DO NOT create the objects) May also allocate storage if part of the object is heap-dynamic Can include parameters to provide parameterization of the objects Implicitly called when an instance is created Can be explicitly called Name is the same as the class name
  • 6. ICS 313 - Fundamentals of Programming Languages 6 11.5 Language Examples (continued) C++ (continued) Destructors Functions to cleanup after an instance is destroyed; usually just to reclaim heap storage Implicitly called when the object’s lifetime ends Can be explicitly called Name is the class name, preceded by a tilda (~) See class definition for stack (p. 447) and the example program that uses it (p. 448) Friend functions or classes - to provide access to private members to some unrelated units or functions (NECESSARY in C++) Evaluation of C++ Support for Abstract Data Types Classes are similar to Ada packages for providing abstract data types Difference: packages are encapsulations, whereas classes are types 11.5 Language Examples (continued) A Related Language: Java Similar to C++, except: All user-defined types are classes All objects are allocated from the heap and accessed through reference variables Individual entities in classes have access control modifiers (private or public), rather than clauses Java has a second scoping mechanism, package scope, which can be used in place of friends All entities in all classes in a package that do not have access control modifiers are visible throughout the package See Java class definition for stacks (p. 449-450) and the class that uses it (p. 450)
  • 7. ICS 313 - Fundamentals of Programming Languages 7 11.6 Parameterized Abstract Dats Types Ada Generic Packages Make the stack type more flexible by making the element type and the size of the stack generic See GENERIC_STACK package (p. 451) package INT_STACK is new GENERIC_STACK(100, INTEGER); package FLOAT_STACK is new GENERIC_STACK(500, FLOAT); C++ Templated Classes Classes can be somewhat generic by writing parameterized constructor functions e.g. stack (int size) { stk_ptr = new int [size]; max_len = size - 1; top = -1; } stack (100) stk; The stack element type can be parameterized by making the class a templated class See the templated class stack (p. 452-453) Java does not support generic abstract data types