![Data Structures and Algorithms in C++](https://www.bartleby.com/isbn_cover_images/9780470383278/9780470383278_largeCoverImage.gif)
Data Structures and Algorithms in C++
2nd Edition
ISBN: 9780470383278
Author: Michael T. Goodrich
Publisher: Wiley, John & Sons, Incorporated
expand_more
expand_more
format_list_bulleted
Question
Chapter 2, Problem 18R
Program Plan Intro
A class “Pair”
Program plan:
- Declare the header files and namespace.
- Create a template class “Pair”,
- Declare the public access modifier.
- Declare the generic type variables.
- Define the public access modifier.
- Define the constructor to set the initial values.
- Define the method “display1()” to print the output.
- Declare the public access modifier.
- Define the “main()” function,
- Initialize the necessary constant variables.
- Print the string “Pair 1.”.
- Construct the first object to pair integer and string values.
- Call the method to “display1()” to print the pair of integer and string values.
- Print the string “Pair 2.”.
- Construct the second object to pair float and long type values.
- Call the method to “display1()” to print the pair of float and long type values.
- Print the string “Pair 3.”.
- Construct the third object to pair double and char type values.
- Call the method to “display1()” to print the pair of double and char type values.
- Print the string “Pair 4.”.
- Construct the fourth object to pair integer and double type values.
- Call the method to “display1()” to print the pair of integer and double type values.
- Print the string “Pair 5.”.
- Construct the fifth object to pair string and char type values.
- Call the method to “display1()” to print the pair of string and char type values.
- Return “0”.
Expert Solution & Answer
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 2 Solutions
Data Structures and Algorithms in C++
Ch. 2 - Prob. 1RCh. 2 - Prob. 2RCh. 2 - Prob. 3RCh. 2 - Give an example of a software application where...Ch. 2 - Prob. 5RCh. 2 - Draw a class inheritance diagram for the following...Ch. 2 - A derived class’s constructor explicitly invokes...Ch. 2 - Give a short fragment of C++ code that uses the...Ch. 2 - Prob. 9RCh. 2 - Suppose we have a variable p that is declared to...
Ch. 2 - Prob. 11RCh. 2 - Generalize the Person-Student class hierarchy to...Ch. 2 - Prob. 13RCh. 2 - Consider the following code fragment:
class...Ch. 2 - Write a short C++ function that counts the number...Ch. 2 - Write a short C++ function that removes all the...Ch. 2 - Write a short program that takes as input three...Ch. 2 - Prob. 18RCh. 2 - Give an example of a C++ program that outputs its...Ch. 2 - Suppose you are on the design team for a new...Ch. 2 - Most modern C++ compilers have optimizers that can...Ch. 2 - Design a class Line that implements a line, which...Ch. 2 - Write a C++ class that is derived from the...Ch. 2 - Write a C++ class that is derived from the...Ch. 2 - Write a program that consists of three classes, A,...Ch. 2 - Prob. 8CCh. 2 - Write a C++ program that can take a positive...Ch. 2 - Write a C++ program that “makes change.” Your...Ch. 2 - Write a simulator as in the previous project, but...Ch. 2 - Write a C++ program that inputs a document and...
Knowledge Booster
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education