CS253: Software Development with C++

Spring 2018

Linked List

Linked Lists                

This lab concerns the linked lists and dynamic memory allocation.                 

  1. Copy the directory ~cs253/Labs/LinkedList to a convenient place in your home directory.
  2. Compile & link main.cc & ll.cc together.
  3. Create a Makefile so that you won't have to type g++ again. Use at least -Wall.
  4. Run the resultant executable; observe how the program works. Reading the code may help.
  5. Are there any memory leaks? If so, fix them.
  6. Find uses of this->, which are always suspicious. Remove them. Does everything still work?
  7. .initialize() methods often indicate that the author doesn't understand constructors. Turn them into ctors.
  8. Are your ctors using member initialization lists? Make them do so.
  9. The method .remove() uses a pointer argument to return a value. How crass—use a reference, instead.
  10. Add a method .print() that displays the list. Add another case in main() that uses it.
  11. Using .print() is tacky. Replace it with an overloaded << operator so you can use << on a LinkedList object, just like any other type.
  12. Are you sure that you have no memory leaks? What happens when a LinkedList object is destroyed? Fix that.
  13. Show your work to the TA for personal validation and approval of your life choices.

User: Guest                 

Check: HTML CSS
Edit History Source

Modified: 2018-02-13T11:38                 

Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2018 Colorado State University
CS Building