Jump to content
  • Advertisement

Archived

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

lukeyes

Compiler errors with Object Intercommunication

This topic is 5840 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

Ok, I got something pretty frustrating here. When I try to have objects being able to intercommunicate, I get compilers errors when I compile. Let me elaborate. Here''s an exampl of my CBulletList header file, the bullet list checks through the CAliensList object to perform collision detection
  
// Lucas keyes

// CBulletList.h

// this jenga holds all the bullets in the game.


#ifndef __CBULLETLIST__
#define __CBULLETLIST__

#include "CJenga.h"
#include "CBulletObject.h"
#include "CAliensList.h"


class CBulletList {

private:
	CJenga<CBulletObject>* m_pjenga;

public:
	CBulletList() { m_pjenga = new CJenga<CBulletObject>;  }
	~CBulletList() { delete m_pjenga; }
	virtual void Draw(CDXSurface* dest) {  m_pjenga->Draw(dest); }
	virtual void Clean() { m_pjenga->Clean(); }
	virtual void Add(int x, int y) { m_pjenga->AddNode(x,y); }
	virtual void CheckObjectCollision(CAliensList *p_aliens) { p_aliens->CheckObjectCollision(m_pjenga); }

};

#endif
  
everything works peachy keen, if I didn''t want the aliens to fire, thus needing to be able to communicate with another CBulletList object that will hold all of their bullets. here''s the CAliensList header file
  
// Lucas Keyes

// CAliensList.h

// container for all the CAlien objects


#ifndef __CALIENSLIST__
#define __CALIENSLIST__


#include "CTimer.h"
#include "CJenga.h"
#include "CAlien.h"
#include "CBulletObject.h"
#include "CMultiDimArray.h"
#include "CBulletList.h"


extern CTimer timer;

class CAliensList {


private:
	CMultiDimArray<CAlien> *m_pmdarray;
	int m_ilastmovetime;
	int m_nxdirection;
	int m_nydirection;
	int m_inversespeed;
	bool m_balienswon;

public:
	CAliensList();
	~CAliensList(){ delete m_pmdarray; }
	
	void Create();
	void Clean() { m_pmdarray->Clean(); }
	void Draw(CDXSurface *dest) { Move(); m_pmdarray->Draw(dest); }
	void CheckObjectCollision(CJenga<CBulletObject>* p_jenga);

	bool TimeToMove() { return (timer.time() >= m_ilastmovetime + m_inversespeed); }

	void Move();
	void MoveAllAliens();
	bool CheckAllForOffscreen();
	bool CheckAllAtBottom();
	void ReverseDirection();
	void SetYDirection(int dir) { m_nydirection = dir; }
	void CheckForProblems();
	void MoveAllRight();
	void MoveAllLeft();
	void MoveAllDown();
	bool AliensWon() { return m_balienswon; }
	void Think(CBulletList* p_bulletlist);

public:
	enum XDIRECTION {XDIR_NONE = 0, XDIR_LEFT, XDIR_RIGHT};
	enum YDIRECTION {YDIR_NONE = 0, YDIR_DOWN};

};

#endif

  
so, come build time, I get the following error message. C:\Documents and Settings\lucas\My Documents\ProjectFalcon\alientest2\CBulletList.h(24) : error C2061: syntax error : identifier ''CAliensList'' makes sense why it gives that error message, but what can I do to work around this? Any help would be mighty appreciative.

Share this post


Link to post
Share on other sites
Advertisement
2 headers which include each other give you trouble, the way to solve it, is simple : in one of the headers delete the include and before the class definition you put :

class ClassFromOtherHeaderFile;

Share this post


Link to post
Share on other sites
so it''s a class declaration that''s a lot like a function definition? sweetness, i''ll try that out. thanks a bunch.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!