Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that : Write a class template ArrayUtils : template class ArrayUtils { ... }; The above class should contain the following

Write a C++ program that :

Write a class template ArrayUtils:

template

class ArrayUtils {

...

};

The above class should contain the following two member functions:

void print(T array[], int size).-should be able accept an array of any data type and thenumber of elements in the array. The member function should print the elements of the array.

void printReverse (T array[], int size) -should be able to accept an array of anydata type and the number of elements in the array. The member function should print the elements of the array in reverse order.

Note that the above member functions should be defined inside the class declaration, not separately.

The declaration of class ArrayUtils and the main function (given below) should be in a single file named Lab6Part1.cpp

int main() {

ArrayUtils<int> au1;

int arr1[3] = {2, 4, 6};

au1.print(arr1, 3);

au1.printReverse(arr1, 3);

ArrayUtils au2;

string arr2[3] = {"abc", "def", "ghi"};

au2.print(arr2, 3);

au2.printReverse(arr2, 3);

}

Output:

2 4 6

6 4 2

abc def ghi

ghi def abc

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

Students also viewed these Databases questions

Question

Is there a link between chronic stress and memory function?

Answered: 1 week ago

Question

LO3 Discuss the steps of a typical selection process.

Answered: 1 week ago