Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In c++, Write a templated function (named make_double) that takes two arguments: An array pointer reference of a templated type A size_t reference which is

In c++, Write a templated function (named "make_double") that takes two arguments:

An array pointer reference of a templated type

A size_t reference which is the size of the array

This function should make the array pointer reference point at a new dynamic array that is twice the size and has two copies of each original value in the array. It should also make the sz reference have the double size.

// Example usecase: #include  using std::copy; #include  using std::vector; size_t sz = 3; long * ary_ptr = new long[sz]{1, 2, 3}; make_double(ary_ptr, sz); ASSERT_EQ(6, sz); vector expected{1, 2, 3, 1, 2, 3}; vector result(sz); copy(ary_ptr, ary_ptr + sz, result.begin()); ASSERT_EQ(expected, result); 

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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions