220 Midterm Notes - Template Class: A template class is a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Template Class: A template class is a class that stores and processes a collection of information. The data type of this information is a parameter that is specified when the template class is instantiated. Template<typename T> Class some_container {…} Some_container is declared as template class. Parameter T is a placeholder for the actual data type of the information to be stored in some_container. How is a Template Class used? Some_container<int> call_lengths; Some_container<Person> people; This will create 2 instances of the class. One storing int values, the other storing Person objects. Vector Template class, enhancement of array. Increase/decrease length, insert element at a specific position without writing code to shift the other elements to make room. Remove an element at a specified position without writing shift. Iterator An object that accesses the objects contained in a sequence one at a time Efficiency Polymorphism Allows values of different data types to be handled using a uniform interface. The concept of polymorphism applies to both data types and functions . A function that can evaluate to or be applied to values of different types is known as a polymorphic function Single-linked List List of Nodes linked by data Next. Next of last element is NULL
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

220 Midterm Notes - Template Class: A template class is a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online