Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
Question
Book Icon
Chapter 17, Problem 7PP
Program Plan Intro

Creation of program to construct template class to implement a set of items

Program Plan:

  • Define a class “Set” to define properties and methods.
    • Define a constructor “Set()” to create instance.
    • Define a destructor “~Set()” to destroy set.
    • Define a method “operator=()” to define overloaded function.
    • Define a method “add()” to add new items.
    • Define a method “remove()” to remove item from set.
    • Define a method “size()” to get size of set.
    • Define a method “contains()” to check whether an element is in set.
    • Define a method “to_array()” to copy values.

Blurred answer
Students have asked these similar questions
in kotlin, Use this Employee class data class Employee(val name: String, val wage: Double, val hours: Double) and this list of Employees: val l: List = listOf(Employee("Bob", 34.33, 42.0), Employee ("Cathy", 27.33, 15.25), Employee("Carlos", 46.99, 38.75), Employee("Tomas", 49.66,28.45), Employee("Xavier", 34.56, 11.5)) Write a function called raise which takes a list of Employees and a Double and returns a list of Employees like the original but with each having received a raise, with the Double representing the percentage raise. For example, if an employee's wage was $20 per hour and the Double is .15 (that is, 15%), her new wage will be $23 per hour. Don't change the Employees; create and return a list of new Employee objects with the new wages. Use Kotlin's map() function.
Write a template-based class that implements a set of items.  The class should allow the user to: Add a new item to the set(addition of new item if already element then it will completely ignored) Get the number of items in the set Test your class by creating sets of different data types (e.g. integers, strings, etc.)   Please use the following class template to finish the program.  MAX 100 template<class T> class Set { public: Set(); void add(T newItem);// Add new item to the set (definition should be outside of the class) int getSize();// Return size of set (definition should be outside of the class) private: int numOfelements;  T data[MAX]; };
Q# In Java, if you see a class name followed by “<T>”, as in List<T>, what does this mean?Group of answer choices 1.It is what is called a lambda-function. 2.It’s for making collections of objects of many types at the same time. For example, if I make List<T> myList = new List<T> I can put a String as one item, an int as another, and a Random as a third item. 3.You must specify an object type in place of the T; eg. List<Shape> will make a list of Shape objects. 4. It means that the object is of type Time.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning