Starting from:
$35

$29

Project #1 Templated Dynamic Array Solution




 
Overview




For this project, you will implement a templated dynamic array class. The array can grow as necessary as new elements are added to the array. Futher, you will implement a iterator for your array that exists to "refer to" or "point to" an existing element in the array. The required API's are speci ed in the array.h le. The main folder of your solution should be named p1 (note capitalization). Starter code is provided for this project on Canvas.




 
Checking for Memory Leaks




An important requirement for this assignment is to properly management and to have ZERO MEMORY LEAKS IN YOUR CODE. On pace-ice you can run the valgrind program, which gives detailed memory usage statistics and leak statistics, Run valgrind as follows :




valgrind --tool=memcheck ./p1




At the end of execution, valgrind prints a summary of memory leaks. You want "All heap blocks were freed { no leaks are possible." to appear at the end. Students will lose points per memory leak on this assignment.




 
in-place new and delete




Recall that we said in class that the new operator, by default, does two seperate and independent things. First is to nd some memory to store the new object, and second is to call the constructor for the object. In this assignment you will often want to call a constructor, but to use existing memory. This is called an in-place new. The syntax is :




new (address) constructor




The address is the address of an existing memory region where the new object will be stored. The constructor is the constructor.




Similarly the delete operator does two independent things. First is to call the destructor for the object, and the second is to free the memory associated with the object. Again, in this assignment you will frequently want ot call the destructor for the object, but do not want the memory freed. Give an object of type T, the syntax for in-place delete is :




object.˜T();




Here object is a variable of type T.




 
Grading




For grading we will run multiple tests on your dynamic array testing functionality. Points will be deducted for memory leaks and incorrect implementation.




 
Submission




For submission, compress your solution into p1.zip (NOT .TAR.GZ, or .RAR or anything else). zip is installed on the login node. Submit via canvas.
















1

More products