Question: THIS IS THE SECOND TIME I'M POSTING THIS QUESTION BECAUSE I DIDN'T GET A RESPONSE. A RESPONSE IS NEEDED BY 12 pm TODAY. I need

THIS IS THE SECOND TIME I'M POSTING THIS QUESTION BECAUSE I DIDN'T GET A RESPONSE. A RESPONSE IS NEEDED BY 12 pm TODAY.

I need help with the following program. I'm using C++ and vim. It doesn't have to be anything fancy, just one variable for each program. The first picture has the problem, the second picture has the three different types of functions I'm supposed to use. Thanks!

THIS IS THE SECOND TIME I'M POSTING THIS QUESTION BECAUSE I DIDN'T

GET A RESPONSE. A RESPONSE IS NEEDED BY 12 pm TODAY. I

(4 pts) Understand Pointers/Dynamic Memory Write 3 different functions in C++ to create memory on the heap without causing a memory leak. Hint: You will need to assign the address to a pointer that was created outside the function. Remember, you can return an address or change what a pointer points to (the contents of a pointer) in a function by passing the pointer by reference or by passing the address of the pointer. What if you want to change the contents of what the pointer points to? Make a function that will set the contents of the space on the heap. Do you still need to pass by reference or the address of the pointer? Why or why not? How will you delete the memory off the heap? Try doing it outside a function, now inside a function. Make sure your delete function is setting your pointer back to NULL, since it is not supposed to be pointing anywhere anymore. You can check to see if you have any memory leaks using valgrind %valgrind program-exe

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!