Concept explainers
Define a class called StringSet that will be used to store a set of STL strings. Use an array or a vector to store the strings. Create a constructor that takes as an input parameter an array of strings for the initial values in the set. Then write member functions to add a string to the set, remove a string from the set, clear the entire set, return the number of strings in the set, and output all strings in the set. Overload the + operator so that it returns the union of two StringSet objects. Also overload the * operator so that it returns the intersection of two StringSet objects. Write a program to test all member functions and overloaded operators in your class.
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Degarmo's Materials And Processes In Manufacturing
SURVEY OF OPERATING SYSTEMS
Modern Database Management
Java: An Introduction to Problem Solving and Programming (8th Edition)
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
- Programming language C++arrow_forwardC# Create class IntegerSet. Each IntegerSet object can hold integers in the range 0–100. The set is represented by an array of bools. Array element a[i] is true if integer i is in the set. Array element a[j] is false if integer j is not in the set. The parameterless constructor initializes the array to the “empty set” (i.e., a set whose array representation contains all false values.) • Provide the following methods: a) Method Union creates a third set that’s the set-theoretic union of two existing sets (i.e., an element of the third set’s array is set to true if that element is true in either or both of the existing sets—otherwise, the element of the third set is set to false). b) Method Intersection creates a third set which is the set-theoretic intersection of two existing sets (i.e., an element of the third set’s array is set to false if that element is false in either or both of the existing sets—otherwise, the element of the third set is set to true). c) Method…arrow_forwardDon't use vector array .using c++ languagearrow_forward
- javascript Define a function, myIncludes, that accepts two parameters: an array and a searchValue. myIncludes should return true if the searchValue is an element in the array. Otherwise, myIncludes should return false. example myIncludes([10, 20, 30], 20); // => true myIncludes(['apples', 'bananas', 'citrus'], 'pears'); // => falsearrow_forwardCould you correct the errorarrow_forwardIn java Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated. Develop a function that returns true if the elements are in decreasing order and false otherwise. A “peak” is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks. Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8, 1, 4, 6}, the function would return 6, since the subsequence {1, 4, 6} is the longest that is strictly increasing. Develop a function that takes a string…arrow_forward
- #include #include using std::cout; using std::vector; class StatSet { private: HCreate a vector of doubles that is called "numbers." public: //Nothing to do in the constructor. StatSet() } // Add a new number to the set. vòid add_num(double num) { } double mean() { //Sum up the values and return the average. double sum = 0; //Write a loop that would iterate through the vector. sum += numbers[i]; return sum / numbers.size(); } double median() //Before calculating the median, we must sort the //array.arrow_forwardJava (ArrayList) - Plant Informationarrow_forwardmergeAndRemove(int[], int[]) This is a public static function that takes a int[] and int[] for the parameters and returns an int[]. Given two arrays of integers. Your job is to combine them into a single array and remove any duplicates, finally return the merged array.arrow_forward
- Procedure: Develop an extension of structure.Vector, called MyVector, that includes a new method, sort. Here are some steps toward implementing this new class: 1. Create a new class, MyVector, which is declared to be an extension of the structure.Vector class. You should write a default constructor for this class that simply calls super();. This will force the structure.Vector constructor to be called. This, in turn, will initialize the protected fields of the Vector class. 2. Construct a new Vector method called sort. It should have the following declaration: public void sort(Comparator c) // pre: c is a valid comparator // post: sorts this vector in order determined by c This method uses a Comparator type object to actually perform a sort of the values in MyVector. You may use any sort that you like. 3. Write an application that reads in a data file with several fields, and, dependingarrow_forwardWrite in Java pleasearrow_forwardC CodeApproved Libraries:<string.h> *not allowed in some questions<math.h><stdlib.h><time.h> (for srand(time(0)) only)arrow_forward
- 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