What to do
Take your latest Car and List class code. Add functions to the List class that asks the user for a model and then deletes the first match in the list (or just assume all makes are unique in the list).
HINT: Add a deleteCar function to get the make and then call a deleteFromList with the C-String to actually delete the car object from the list.
Memory Leaks with Valgrind
Use valgrind to see if you have any memory leaks. To do this, use the following command:
valgrind --tool=memcheck --leak-check=full prog
replace 'prog' with the name of your program. Please enter at least 3 cars, print them out and quit.
When the program ends, you will get a memory leak report. Look over the last lines of output. In comments in your main.cpp file, record how much memory is leaked for each category (or if you can, you can cut and paste the information). I'm NOT going to take off points for memory leaks shown, just want you to be aware of how to read valgrind output. In assessment 5, you will need to find and fix any memory leaks you have in your code.
NOTE: The iostream library has a memory leak of 72,704 bytes. You are not re- sponsible for this but anything above this is a leak in your program.
Requirements
- Either run the 'script' command OR copy the valgrind output to a text file.
- Must have a linked list in your List class. NO ARRAYS (except for temporary C strings).
- Need functions for deleting a car from the list by model.
- Need a destructor for the List class.
-
Must have dynamic C strings in your Car class. No fixed arrays.
- Must have 6 files: car.h, car.cpp, list.h, list.cpp, main.cpp and a makefile
- No function definitions in the car.h or list.h file. Only prototypes.
Output:
EXAMPLE OUTPUT
3 - delete a car
4 - quit
2
Enter make: Honda
Enter model: Civic
Enter year: 2018
1 - print list of cars
2 - add a car
3 - delete a car
4 - quit
1
make: Honda
model: Civic
year: 2018
1 - print list of cars
2 - add a car
3 - delete a car
4 - quit
2
Enter make: Ford
Enter model: Escort
Enter year: 2002
1 - print list of cars
2 - add a car
3 - delete a car
4 - quit
1
make: Honda
model: Civic
year: 2018
make: Ford
model: Escort
year: 2002
1 - print list of cars
2 - add a car
3 - delete a car
4 - quit
2
Enter make: Pierce
Enter model: Arrow
Enter year: 1933
1 - print list of cars
2 - add a car
3 - delete a car
4 - quit
1
make: Pierce
model: Arrow
year: 1933
make: Honda
model: Civic
year: 2018
make: Ford
model: Escort
year: 2002