Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please can you help me answer this question, c++ , also if you can send the zipped file to molugbamila@gmail.com . Question 3. min/max Template.

please can you help me answer this question, c++ , also if you can send the zipped file to molugbamila@gmail.com . Question 3. min/max Template. image text in transcribed
image text in transcribed
image text in transcribed
PROBLEM 1 Gaddis Chapter "Exceptions and Templates Programming Challenge "Min / Max Templates" (#3 in the "early objects") Please call your functions myMin and myMax for this problem. You can do all your work in a file called min Max.cpp that houses your main and the functions. receives a string by value and passes it on to the base class constructor B) An char operator (int k) function that throws a BoundsException object if k is negative or is greater than or equal to the length of the string. If k is within the bounds of the string, this function will return the character at position k in the string. You will need to write the definition of the BoundsException class. Test your class with a main function that attempts to access characters that are within and outside the bounds of a suitably initialized BCheckString object. 2. Arithmetic Exceptions Write a function that accepts an integer parameter and returns its integer square root. The function should throw an exception if it is passed an integer that is not a perfect square. Demonstrate the function with a suitable driver program. he s 3. Min/Max Templates Write templates for the two functions min and max. min should accept two arguments and return the value of the argument that is the lesser of the two. max should accept two arguments and return the value of the argument that is the greater of the two. Design a simple driver program that demonstrates the templates with various data types. 4. Sequence Accumulation Write a function T accum (vector v) ther forms and returns the sum of all items in the vector y passed to it For example PROBLEM 2 your main and the functions. Create a class template Pair that houses 2 items of datatype T. Whatever datatype stored needs to implement the operators. There should be two private data attributes called item1 and item2. There should be the following public methods. A 2 argument constructor. A method getMax that returns the larger of the two stored items. A method getMin that returns the smaller of the two stored items. A method setitems that takes in two constant items by reference and sets item1 and item2 to them. A method getItem1 that returns item 1. A method getItem2 that returns item2. Make a appropriate methods const so they don't alter item1 or item2 if not needed. You should have a Pair.h and Pair.cpp file. Create a pairTest.cpp file with a main() that creates two pairs, one that houses ints an one that houses strings. Test all the methods for these two Pairs in your main and display the results

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Explain pre-employment screening and background checks.

Answered: 1 week ago

Question

KEY QUESTION Refer to columns 1 and 6 in the table for question

Answered: 1 week ago