Casting Problem (probaly simple)

Started by
2 comments, last by Spider_In_A_Web 22 years, 6 months ago
Afternoon all, Please help, my hair seems to appear in my hands in rather large chunks with this, i cannot solve it and the only fix i can think of means making a complete mess of my code and having similar functions all over the place!! Iam working with various linked lists created of inherited objects from the same base, each list only deals with one type of object, but i wanted the base class to handle all linked list functionality. I have a function to add elements to the list, but i want to be able to pass in a pointer to the function, and have the function update that pointer for me!! I figure the way to do this is with a long pointer which i have tried but i keep getting casting errors whenever i try to compile it The code is void AddEnd(CObject** pList, CObject* pNew) { if(pList) { &pList->AddNext(pNew); } else *pList = pNew; } and the error is C:\Documents and Settings\paul\My Documents\AsteroidsV2\Object.cpp(23) : error C2227: left of ''->AddNext'' must point to class/struct/union This has to be due to casting, but i cannot sus it out!! Help me please!!
Advertisement
It was simple :-)

I found the correct cast, sorry for anyone who troubled them selves

The answer is this

(*pList)->AddNext(pNew);

on line 5

ta
Glad you found your error ... have you considered using STL for your linked list?

--

MP3 Dancer

Get A Stripper on your desktop

no, never have, dont know why!!

PS, id prefer a real stripper on my real desktop!!

This topic is closed to new replies.

Advertisement