Homework Help Question & Answers

please answer this c++ question if you know all the questions not just some of them ... thanks Problem 4: Rewrite the f...

please answer this c++ question if you know all the questions not just some of them ... thanks

Problem 4: Rewrite the following function so that it can operate on arrays of any data type, not just integers. You may assum

Problem 4: Rewrite the following function so that it can operate on arrays of any data type, not just integers. You may assume that all operations and comparisons are defined for all data types that we would pass into this function: int cloneArrayReturnMax(int* arr1, int size1, int* arr2, int size2) { size1 int end size2 if (end > size2) end for (int i = 0; i = 0; i--) if (max
0 0
Next > < Previous
ReportAnswer #1

We can use templates in C++ if we want to use for many data types.

1. Replace the line

int cloneArrayReturnMax(int* arr1, int size1, int* arr2, int size2) {

with

template <typename T>
T cloneArrayReturnMax(T* arr1, int size1, T* arr2, int size2) {

2. Replace the line

int max = arr1[ size1 - 1 ]

with

T max = arr1[ size1 - 1 ]

Add Homework Help Answer
Add Answer of:
please answer this c++ question if you know all the questions not just some of them ... thanks Problem 4: Rewrite the f...
Your Answer: Your Name: What's your source?
Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
More Homework Help Questions Additional questions in this topic.
Need Online Homework Help?
Ask a Question
Get FREE Expert Answers
WITHIN MINUTES
Related Questions