Question: Q 1 : Write a C + + function that takes an array as a parameter. The function should create and return a new dynamic

Q1: Write a C++ function that takes an array as a parameter. The function should create and return a new dynamic array that is double the size of the original array.Side Note: I understand that regular static arrays cannot be used to complete the task in Q1 unless the sizes are defined using fixed constant values. Initially, I asked ChatGPT if it was possible to complete Q1 using static arrays without constants for the sizes, and it responded affirmatively, even providing the following incorrect code snippet:// Define the new array size as double the original array sizeint newSize =2* originalSize;// Declare the new array with double the size of the original arrayint newArray[newSize];I then asked, 'Did something change about C++? Can we now use variables to define the size of static arrays?'ChatGPT clarified: In C++, the size of an array must be a compile-time constant. You cannot use a variable to define the size of a static array directly because the array size needs to be known at compile time for the compiler to allocate the appropriate amount of memory.The Point: DO NOT TRUST CHATGPT. Q2: Using a pen and paper, illustrate and compare pointers and references in C++. No typing allowed. Draw a memory stack depicting memory locations and demonstrate how pointers and references function. take a picture for your answer and post it in a word document and upload it.

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 Databases Questions!