Archived

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

RenegadeKoolAid

Weird problem defining an external class

Recommended Posts

Im stumped, I really cant find the answer here but Im sure its just some stupid syntax error I have somewhere...anyway: I have an external class that handles projectiles, in a header file such as:
#include "CGlSetup.h"

#ifndef _CLASERENGINE_H_
#define _CLASERENGINE_H_ 

class CLaserEngine
{
private:

	struct LaserCoords
	{
		GLfloat x;
		GLfloat y;
	};

	LaserCoords m_Lasers[10];

	int m_Filled;

public:

	CLaserEngine( );
	~CLaserEngine( );

	bool AddLaserCoords( GLfloat x, GLfloat y );
	void DeleteOffscreenLaserCoords( GLfloat ShipPosX );
	//void DeleteCollisionLaserCoords( );          //finish later

	void DisplayLasers( GLuint EffectBase, GLfloat ShipPosX );
};

#endif 
Now when I declare it in my main file, such as:
#include "CGlSetup.h"
#include "CSpriteEngine.h"
#include "CLaserEngine.h"

GLuint  g_ShipBase;             //holds beginning of ship sprite display list
GLuint  g_EffectBase;           //holds beginning of effects display list

CGlSetup        g_Setup( "Star Lad", 800, 600, 16, FALSE ); //initialize opengl setup class
CSpriteEngine   g_Sprites( 3 );                             //initialize sprite/texture class
CLaserEngine    g_Lasers( );                                //initialize laser handling class
 
This is how Ive defined my classes countless times, VC++ even pops up that little box identifying g_Lasers as a declaration of the laser engine, but when I try to use it in my main file like:
g_Lasers.DeleteOffscreenLaserCoords( );
			g_Lasers.DisplayLasers( g_EffectBase, g_xpos ); 
I get errorC2228: left of ''.DeleteOffscreenLaserCoords'' must have class/struct/union type. Like I said its probably some some error somewhere, but another pair of eyes on this would be great, Ive been trying for the last 3 hours to fix this and getting agitated. Thanks guys.

Share this post


Link to post
Share on other sites
I could be wrong, but I think the compiler is seeing the line:
CLaserEngine g_Lasers( );
as the declaration of a function that takes no parameters and returns a CLaserEngine.

Share this post


Link to post
Share on other sites