Jump to content
  • Advertisement


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


Weird problem defining an external class

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

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"


class CLaserEngine

	struct LaserCoords
		GLfloat x;
		GLfloat y;

	LaserCoords m_Lasers[10];

	int m_Filled;


	CLaserEngine( );
	~CLaserEngine( );

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

	void DisplayLasers( GLuint EffectBase, GLfloat ShipPosX );

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

  • 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!