Question

I'm a little rusty in C++ and I'm having issues with a Queue class. Basically I can't convert from a class type to a pointer(which makes sense but I need to accomplish something similar).

Here's an example:

void ClinicQueue::removeFront()
{ // Start of removeFront
    ClinicNode* Penultimate;
    ClinicNode* Current;
    ClinicNode* CurrentCopy;
    CurrentCopy = ClinicNode();//Cannot convert ClinicNode to ClinicNode* in assignment
    if (back == front)
    {
        Current = front; 
        CurrentCopy->modify(Current); //No matching function
        //(wants a ClinicNode arg not ClinicNode*)
        front = back = NULL; 
        delete Current;
    }
    else 
    {
        Penultimate = back; 
        while (Penultimate -> next != front) Penultimate = Penultimate -> next;
        Current = front; 
        Penultimate -> next = NULL; 
        CurrentCopy->modify(Current);//No matching function
        //(wants a ClinicNode arg not ClinicNode*)
        delete Current; 
        front = Penultimate; 
    } 
    size--;
} // End of removeFront

What I need is to maintain the same functionality while avoiding the illegal conversion....that is the ClinicNode pointers need to retain their functionality if they are no longer being used as pointers. Any advice is greatly appreciated.

Was it helpful?

Solution

You are missing the new keyword:

CurrentCopy = new ClinicNode();

But your function needs a lot of conceptual work, maybe you should start with that. You are trying to return something in a void function for example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top