How do I return the data in the last node from the RemoveTail function? Currently I have something like below.This is a basic doubly linked list.

class List;
class Node {

    Node* next;
    Node* prev;
    void* data;


        Link( void* pData ) :
            next( 0 ), prev( 0 ), data( pData )

    friend class List;

class List {

    Node* head;
    Node* tail;


        List() :
            head( 0 ), tail( 0 )

        void* RemoveTail();
        //more funtions...

void List::RemoveTail() //removes last node & returns pointer to object contained in it
    if(tail == head)
        void* data = tail->data; //This didn't work
        delete tail;
        head = tail = 0;
        return data;

The void* data = tail->data; isn't working. Is there any other way to do this?

The void* data = tail->data; isn't working.

What do you mean by "isn't working"? The code you posted clearly isn't your actual code, so I can't say for sure what the problem is.

This question has already been answered. Start a new discussion instead.