Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ please, Thank you so much Create a new project. Lets use the array arr below as our example: 6 2 3 2 6

In C++ please, Thank you so much

Create a new project.

Lets use the array arr below as our example:

6

2

3

2

6

2

1. Define the template function

template

int count_exact(T1 a[], T2 size, T1 find)

that returns the number of times find occurs in a. For instance, count_exact(arr, 6, 2) would return 3. Test your function in your main() using an array of ints, and an array of strings. Write a comment explaining which operations the types T1 and T2 need to support for your code to work.

2. Define the template function

template

int count_range(T1 a[], T2 size, T1 low, T1 high)

that returns the number of times an item between low and high (inclusive) occurs in a. For instance, count_range(arr, 6, 2, 4) would return 4. Test your function in your main(). Write a comment explaining which operations the types T1 and T2 need to support for your code to work. Test your function in your main using an array of ints, and an array of strings.

Part B: n-point template class. Create a new project.

1. In this problem, youll make a template class for an n-dimensional point; that is, points with 2, 3, 4, etc. coordinates, up to 10. For example, you could have any of the following:

  • A two-dimensional point of ints, like (2, 6)
  • A five-dimensional point of strings, like (Hello, how, are, you, today)

Your class should have private members as follows: an array of size 10, and a variable that holds the dimension of the point. Also include:

  • Three constructors: one constructor that takes 0 arguments, one that takes in just the dimension of the point, and one that takes in the dimension of the point and the initializing array.
  • A single getter that returns the ith item in the tuple
  • A getter for the size

Test your functions in your main().

2. Overload the = operator for your class as a member. Write a comment explaining which operations the type variable needs to support for your code to work. Your = function should be void. Test your function in your main().

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

What are the main forces for and impediments to change?

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago