Jump to content
  • Advertisement

Archived

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

disanti

Confusing Class Error.

This topic is 5188 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, I''m getting the following errors: D:\Santi Productions\PSS4086\leveldata\levelobjects.h(5) : error C2236: unexpected ''class'' ''levelobject'' D:\Santi Productions\PSS4086\leveldata\levelobjects.h(5) : error C2143: syntax error : missing '';'' before ''{'' D:\Santi Productions\PSS4086\leveldata\levelobjects.h(5) : error C2447: missing function header (old-style formal list?) With the following code:
#ifndef _LEVEL_OBJECTS___
#define _LEVEL_OBJECTS___

class levelobject
{ //LINE OF ERROR

public:
	//constructor

	levelobject() {};

	//sets

	inline void setType(int is) {type = is;};
	inline void setTextureFlag(int flag) {textureFlag = flag;};
	inline void setLight(bool light) {useLight = light;};
	inline void setXYZ(float a, float b, float c)
	{
		x = a; y = b; z = c;
	};
	inline void setScale(float s) {scale = s;};
	inline void setRotation(float a, float b, float c)
	{
		rotx = a; roty = b; rotz = c;
	};
	inline void setPortalXYZ(float a, float b, float c)
	{
		portalx = a; portaly = b; portalz = c;
	};
	inline void setSpeedFactor(int s)
	{
		speed = s;
	};
	inline void setAI(int ai)
	{
		ai_num = ai;
	};
	inline void setLevel(int m)
	{
		levelnum = m;
	};

private:
	//positions/rotations/scale

	float x,y,z,scale,rotx,roty,rotz;
	//portal settings

	float portalx,portaly,portalz;
	//speed factor

	int speed;
	//AI for NPCs

	int ai_num;
	//types

	int type;
	//light

	bool useLight;
	//textureflag

	int textureFlag;
	//level values

	int levelnum;
};

#endif
I spent an hour last night just looking at the class. This is very confusing to me. Thank you!

Share this post


Link to post
Share on other sites
Advertisement
You don't need the semi-colons after your function if you implement it within the class.

Other than that, I cant see anything wrong with it at first glance. (Im not even sure if what I just stated is an error)

[edit]
Yeah, just in case Ill show you what I meant. You can just use levelobject() {} instead of levelobject() {};

[edited by - porthios on February 29, 2004 12:31:49 PM]

Share this post


Link to post
Share on other sites
That didn''t help any!

I''ve had those semi colons behind my functions in every class function I have ever made with no errors. I''m still getting the same errors when removing those.

Thanks~ John DiSanti

Share this post


Link to post
Share on other sites
hi
the problem should be somewhere before including this file, may be some unclosed { or... so the preprocessor reached the class keywork within the definition of a function or so.

Look the file before this file to find the source of error.

Share this post


Link to post
Share on other sites
Ok, full errors:
--------------------Configuration: leveldata - Win32 Release--------------------
Compiling...
main.cpp
D:\Santi Productions\PSS4086\leveldata\levelobjects.h(5) : error C2236: unexpected ''class'' ''levelobject''
D:\Santi Productions\PSS4086\leveldata\levelobjects.h(5) : error C2143: syntax error : missing '';'' before ''{''
D:\Santi Productions\PSS4086\leveldata\levelobjects.h(5) : error C2447: missing function header (old-style formal list?)
D:\Santi Productions\PSS4086\leveldata\level1.h(13) : error C2146: syntax error : missing '';'' before identifier ''lvlobjects''
D:\Santi Productions\PSS4086\leveldata\level1.h(13) : error C2501: ''levelobject'' : missing storage-class or type specifiers
D:\Santi Productions\PSS4086\leveldata\level1.h(13) : error C2501: ''lvlobjects'' : missing storage-class or type specifiers
D:\Santi Productions\PSS4086\leveldata\level1.h(45) : error C2146: syntax error : missing '';'' before identifier ''getObject''
D:\Santi Productions\PSS4086\leveldata\level1.h(45) : error C2501: ''levelobject'' : missing storage-class or type specifiers
D:\Santi Productions\PSS4086\leveldata\level1.h(48) : warning C4183: ''getObject'': member function definition looks like a ctor, but name does not match enclosing class
Error executing cl.exe.

Code that includes the class (this is the only file that includes it so far):

#ifndef _LEVEL1_H_
#define _LEVEL1_H_

#include "main.h"
#include "levelobjects.h"

//level 1 class

class pss4level1
{
bool created;
bool destroyed;

levelobject lvlobjects[10];
public:
//constructor

pss4level1() {};

//level 1 functions

void createLevel1()
{
if(!created)
{
created = true;

//level mesh/////////////////////////////////////

lvlobjects[0].setType(TYPE_LEVEL);
lvlobjects[0].setLevelNum(1);
//END level mesh/////////////////////////////////


//portals////////////////////////////////////////

lvlobjects[1].setType(TYPE_PORTAL);
lvlobjects[1].setXYZ(2,2,2);
lvlobjects[1].setPortalXYZ(100,100,100);
lvlobjects[1].setLight(false);
lvlobjects[1].setScale(25);
lvlobjects[1].setTextureFlag(TEX_FLAG_ADDCOLOR);
//END portals////////////////////////////////////


//doors//////////////////////////////////////////


//END doors//////////////////////////////////////

}
};

levelobject getObject(int num)
{
return lvlobjects[num];
};

inline void destroyLevel1()
{
if(created)
{
destroyed = true;
created = false;
}
};
};

#endif

Share this post


Link to post
Share on other sites
quote:
Original post by porthios
You don''t need the semi-colons after your function if you implement it within the class.

Other than that, I cant see anything wrong with it at first glance. (Im not even sure if what I just stated is an error)

[edit]
Yeah, just in case Ill show you what I meant. You can just use levelobject() {} instead of levelobject() {};

Let''s make this a little more explicit: Function definitions in C++ are not terminated by semicolons. Function prototypes are, as are classes (whether declared by the struct keyword or the class keyword), but function definitions are not.

Share this post


Link to post
Share on other sites
Ok, next its going to be defines.h and on and on! XP
main.h:


#ifndef _PSS4_LEVELS_DLL___
#define _PSS4_LEVELS_DLL___

//includes//

#include "..\src\defines.h"
#include "level1.h"

//levelsdll - this class contains all of the dll functions

class levelsdll
{
public:
//constructor

levelsdll() {};

void setLevel(int levelnumber)
{
levelnum = levelnumber;
makeLevel();
};

void makeLevel()
{
if(levelnum == 0 || levelnum == 1)
{
pss4level1 level1;
level1.createLevel1();
}
else if(levelnum == 2)
{

}
};

private:
//levels

int levelnum;
};

#endif //_PSS4_LEVELS_DLL___

Share this post


Link to post
Share on other sites
Could be a cyclic dependency:

Level1.h includes main.h
Main.h includes Level1.h

Remove the line #include "Main.h" from level 1
AFAIK it should be OK

[edited by - psamty10 on February 29, 2004 4:09:42 PM]

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!