Give the definition of a template class called HeterogeneousPair that is like the class template Pair discussed in the section “Syntax for Class Templates,” except that with HeterogeneousPair the first and second positions may store values of different types. Use two type parameters T1 and T2; all items in the first position will be of type T1, and all items in the second position will be of type T2. The single mutator function setElement in the template class Pair should be replaced by two mutator functions called setFirst and setSecond in the template class HeterogeneousPair. Similarly, the single accessor function getElement in the template class Pair should be replaced by two accessor functions called getFirst and getSecond in the template class HeterogeneousPair.
Want to see the full answer?
Check out a sample textbook solutionChapter 17 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects (9th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Mechanics of Materials (10th Edition)
SURVEY OF OPERATING SYSTEMS
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- Using C++ make a set of function templates that have these features: This function must return a value. A function template with 1 template parameter, T. And, any other parameters you want. A function template with 2 template parameters, T1 and T2. And, any other parameters you want. Using your own creativity, make a set of class templates that have these features: For this class template, put everything in one place--do not declare the member functions and have separate definition of the member functions elsewhere. Keep them in one place. Include a private variable. Include a constructor that loads the private variable when constructed. Include a destructor that clears the private variable to zero. Include set and get functions to set and get the private variable. For this class template, use declarations for variables and functions, like you do in header file (which you may use if you want). Then, separately put the full function definitions for each class member function…arrow_forwardPlease answer in c++. Create a template class UniversalArray which createss an array of a given ssize, which is part of template declaration as given below: template<typename T, typename T1, int ArraySize> Besides the consstructor and destructor, the class should include:arrow_forwardUsing C++ Using your own creativity, make a set of class templates that have these features: For this class template, put everything in one place--do not declare the member functions and have separate definition of the member functions elsewhere. Keep them in one place. A class template with 2 template parameters, T1 and T2. Include a private variable. Include a constructor that loads the private variable when constructed. Include a destructor that clears the private variable to zero. Include set and get functions to set and get the private variable. For this class template, use declarations for variables and functions, like you do in header file (which you may use if you want). Then, separately put the full function definitions for each class member function on their own, like you do in a separate implementation file (which you may use if you want). Include at least 2 private variables. Include a constructor that loads the private variables when constructed. Include a…arrow_forward
- use case template assignmentarrow_forwardQuestion 4: Write NP (numeric pair) template class that will hold two instances of the given type (x and y). Write default, copy and move constructors; a constructor that takes x and y values, copy assignment, + operator that adds x and y values of the left and right sides separately, and comparison operator which checks if x and y are the same for left and right sides. Additionally, add a function call operator which will return the summation of the two variables. Use const in places that are neededarrow_forwardSo form code should be established in a functional way and outcome also.arrow_forward
- THIS QUESTION IS RELATED TO SUBJECT OBJECT ORIENTED PROGRAMMING IN C++ . SOLVE this question in dev c++. please send it in 30 minutes and solve step by step. THANKS Q#5 Start with the safearay class from the ARROVER3 program in Chapter 8 of Object Orient programming by Rober Lafore. Make this class into a template, so the safe array can store any kind of data. Include following member functions in Safe array class. The minimum function finds the minimum value in array. The maximum function find the maximum value in array. The average function find average of all the elements of an array. The total function finds the running total of all elements of an array. In main(), create safe arrays of at least two different types int and double and store some data in them. Then display minimum, maximum, average and total of array elements. Note: use subscript ([]) operator in sasfearay class.arrow_forwardWrite a complete C++ program that implements the followings: A. A class called Books. The class Books private data members should include: 1. Title: array of 30 char variables. 2. ISBN: pointer to an int variable. 3. Orders: array of 7 double variables. The class Books also should include the following public member functions: 4. For each data member: Title, ISBN, and Orders provide a parametrized Set function to store the received parameters for each one of them. 5. For each data member: Title, ISBN, and Orders provide an empty Get function to return the value for each one of them. 6. Provide the parametrized function TotalCost that returns the Orders summation multiplied by Price. Price a double parameter received by this function. B. The main function should include: 1. Definition for the object OBJ from the class Books. 2. Calling statements for the Set functions of the object OBJ. Prompt to the user to enter arguments to be passed for the functions. 3. Print the information for…arrow_forwardPlease answer in c++. Create a template class UniversalArray which createss an array of a given ssize, which is part of template declaration as given below: template<typename T, typename T1, int ArraySize> Besides the consstructor and destructor, the class should include: getValue(); setValue(); getSize();arrow_forward
- This is in c++ The base class Pet has private data members petName, and petAge. The derived class Dog extends the Pet class and includes a private data member for dogBreed. Complete main() to: create a generic pet and print information using PrintInfo(). create a Dog pet, use PrintInfo() to print information, and add a statement to print the dog's breed using the GetBreed() function. main.cpp #include <iostream> #include<string> #include "Dog.h" using namespace std; int main() { string petName, dogName, dogBreed; int petAge, dogAge; Pet myPet; Dog myDog; getline(cin, petName); cin >> petAge; cin.ignore(); getline(cin, dogName); cin >> dogAge; cin.ignore(); getline(cin, dogBreed); // TODO: Create generic pet (using petName, petAge) and then call PrintInfo // TODO: Create dog pet (using dogName, dogAge, dogBreed) and then call PrintInfo // TODO: Use GetBreed(), to output the breed of the dog } Dog.cpp #include "Dog.h" #include…arrow_forwardImplement the functions given, instructions of what each function needs to do is given in their respective comments. Only need a smart_ptr.h file.arrow_forwardPlease answer in c++. Create a template class UniversalArray which createss an array of a given ssize, which is part of template declaration as given below: template<typename T, typename T1, int ArraySize> Besides the consstructor and destructor, the class should include:arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning