Question: write in c + + . Write a program to output the contents and compare the contents in the array by implementing class templates. First
write in cWrite a program to output the contents and compare the contents in the array by implementing
class templates.
First implement a class template myArray that can store an array of any type:
It has two public members: myArr type: size: and len type: int
It has one public function set to ask for the number of elements and the content of
elements.
It has a public template member function that overloads operator to compare two
myArray objects of type and U Only when two objects are of the same type with the same
length does this operator return true, otherwise it will return false.
Then implement two template functions:
A template function that overloads operator to output the content of myArray object
with type T Each element is separated by a space
A template function that takes two myArray objects with type and sets their values,
prints the contents and checks their equality.
In the main function, users are asked to choose a test case for comparing arrays of different types.
Depending on the input, it creates two myArray objects with the corresponding types and calls the
function to perform the set, print, and comparison operations.
Note: All inputs are valid and the maximum length of the array is less than
CS Computer Programming
ExampleInputs are underlined:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
