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 c++.Write 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: T, size: 20) 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 '=z' to compare two
myArray objects of type T 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 T and U, 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 20.
CS2310 Computer Programming
Example-2(Inputs are underlined):
write in c + + . Write a program to output the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!