40
ZoidBob
7y

Making our own linked list class in C++
This is how he deleted his list in the destructor

~myList() {
delete head;
}

Gets a couple of points off, blames the prof for biased marking

Comments
  • 0
    @Pseudonymous Self proclaimed if nothing else, his instagram, twitter and website say that he's a dev
  • 4
    jeez, talk about a memory leak...
  • 4
    I don't know what is the type of head, but if it is a node object he could write the node's destructor like this so everything will work.

    ~Node() {
    //deletes data field and
    //if the next node is not null
    //deletes the next node
    }
  • 0
    @martikyan Node was a struct, I think the prof saw that one coming
  • 1
    @martikyan yeah, but he didn't
  • 0
    Our professor told us to do exactly that in our clear method.
    Difference is that it's C# and we have no way to manually destroy nodes :(
Add Comment