Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ - bool initilize(int size, int val = 0)- This function will allocate space for the pointer called mArray and fill it with val.

C++ - bool initilize(int size, int val = 0)-\ \ This function will allocate space for the pointer called mArray and fill it with val. Notice that this function has a default argument which sets all elements to 0 if nothing is specified. This function should first check to see if the pointer is not NULL. If it is not NULL then the memory associated with the pointer should be deleted so that you avoid a memory leak. This function should then allocate space for the pointer to create the array. You should use size for the number of bytes to allocate. This function also needs to check to make sure the memory was allocated. If it wasn't the function should simply return false. If the memory was allocated then the size variable in the class should be set and ar filled with val. If everything succeeds then the function will return true. Make sure that the private variable mSize is set to the size of the array.

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions