"cannot convert" error

This is a discussion on "cannot convert" error within the C++ Programming forums, part of the General Programming Boards category; I'm trying to write the delete function of a stack class, and i'm getting the error: error C2440: '=' : ...

  1. #1
    RR1
    RR1 is offline
    Registered User
    Join Date
    May 2003
    Posts
    4

    "cannot convert" error

    I'm trying to write the delete function of a stack class, and i'm getting the error:

    error C2440: '=' : cannot convert from 'struct dataNode *' to 'struct Stack::deleteRec::dateNode *'



    Code:
    class Stack
    { private: 
        struct dataNode* listPtr;
        struct dataNode* endPtr;
        int listSize;
        bool empty();
      public:
        Stack();
        void insert(struct dataNode*);
        void deleteRec();
        int size();
        void show();
    };
    
    
    
    void Stack::deleteRec()
    {  struct dateNode* nextPtr;
       nextPtr = endPtr;
       for (int i=0;i<listSize-1;i++)
       {  nextPtr = nextPtr->next;
       }
       delete nextPtr;
       listPtr=nextPtr;
       listSize--;
    }

    The error is for the second line of the deleteRec. As far as i can see, endPtr is of an identical type as nextPtr so i dont know why it's complaining, especially as it let me do this in another function above it.


    Thanks in advance

  2. #2
    Registered User HaLCy0n's Avatar
    Join Date
    Mar 2003
    Posts
    77

    Re: "cannot convert" error

    Originally posted by RR1
    error C2440: '=' : cannot convert from 'struct dataNode *' to 'struct Stack::deleteRec::dateNode *'
    I'm going out on a limb here. DATEnode and DATAnode seem to be different to me. Hope I'm not stating the obvious.

  3. #3
    RR1
    RR1 is offline
    Registered User
    Join Date
    May 2003
    Posts
    4
    yup pretty obvious but somehow i did't notice that after spending about 15 minutes looking at that function. Althought in my defence, im new to c and i would of assumed that c would have noticed that there is no such struct as datenote and given an error, instead of going straight past it then complaining when i try to refer to it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 03:09 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21