Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

tuxx

Pointers in a linked-list

This topic is 5838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, I''m making a linked list for my mini-engine. I''ll show you the code first, and then explain what''s wrong.
  
class CNode
{
public:
	// Constructors

	CNode();									// Default constructor

	CNode(CNode *next,							// Overloaded constructor

		  CNode *prev,
		  CNode *parent,
		  CNode *child);

	// Destructors

	~CNode();									// Default destructor


private:
	CNode *m_pNext;								// Next node

	CNode *m_pPrev;								// Previous node

	CNode *m_pParent;							// Parent node

	CNode *m_pChild;							// Child node

};

// Default constructor

CNode::CNode()
{
	// Set all pointers to NULL

	this->m_pNext   = NULL;
	this->m_pPrev   = NULL;
	this->m_pParent = NULL;
	this->m_pChild  = NULL;
}
  
My problem is in the definition of the constructor. The errors are basically saying that I can''t assign the pointer to the nodes to NULL. I thought that I was just assigning the pointers to NULL, not the CNode class. This is probably an easy question to answer, and I''m sorry for any newbism in this post, but I''m really baffled. I mean, in the expression:
LPDIRECT3D8 g_pD3D = NULL;
 
That seems to be the same thing, assigning the pointers to NULL. Could anyone help me on this? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
this is funny. you tell us what the error message means, ha, ha.
i think you should post the error message, instead of telling us your interpretation of it.

looks like fallen got it i bet.

[edited by - evilcrap on June 30, 2002 10:46:31 PM]

Share this post


Link to post
Share on other sites
Sorry :

C:\Documents and Settings\Alex Konrad\My Documents\Visual C++ Projects\Panther\CNode.cpp(18) : error C2065: ''NULL'' : undeclared identifier
C:\Documents and Settings\Alex Konrad\My Documents\Visual C++ Projects\Panther\CNode.cpp(18) : error C2440: ''='' : cannot convert from ''int'' to ''class CNode *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\Alex Konrad\My Documents\Visual C++ Projects\Panther\CNode.cpp(19) : error C2440: ''='' : cannot convert from ''int'' to ''class CNode *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\Alex Konrad\My Documents\Visual C++ Projects\Panther\CNode.cpp(20) : error C2440: ''='' : cannot convert from ''int'' to ''class CNode *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\Alex Konrad\My Documents\Visual C++ Projects\Panther\CNode.cpp(21) : error C2440: ''='' : cannot convert from ''int'' to ''class CNode *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

Panther.exe - 5 error(s), 0 warning(s)

There yea go.

Thanks.

Share this post


Link to post
Share on other sites
I changed it to 0, and it worked. I feel so newbish.

Thanks for all of your help!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!