Sign in to follow this  
Hypherion

"new types may not be defined in a return type" error

Recommended Posts

Hypherion    140
I keep getting the error in the title on this code and i can't seem to figure out why. (The SDLGraphics class works ok because i have tested it separately.)
SDLCharacter::SDLCharacter(SDLGraphics* graphics, int imgX, int imgY, int imgW, int imgH,
				 int TransparentRed, int TransparentBlue, int TransparentGreen, 
				 string filename, float maxspeed, int posX, int posY, float angle)
{
	m_graphics=graphics;
	m_imgX=imgX;
	m_imgY=imgY;
	m_height=imgH;
	m_width=imgW;
	m_posX=posX;
	m_posY=posY;
	m_maxspd=maxspeed;
	m_currentspdX=0;
	m_currentspdY=0;
	m_currentAngle=angle;
	m_graphics->imageLoad(filename, TransparentRed, TransparentBlue, TransparentGreen);
	m_image=m_graphics->screenReturn();
	
}

any ideas are apreciated :)

Share this post


Link to post
Share on other sites
deadimp    310
In Compile time (somewhat a stupid question)? What line does the error point to?

EDIT: Ow. Beat by two people in under a minute.

Share this post


Link to post
Share on other sites
Hypherion    140
the error is in the title of the topic... and it's a compilation one.

it's weird because the ide (eclipse) shows me the error on the line where the paranthesis
( "{" ) starts, right after declaring the parameters.

Share this post


Link to post
Share on other sites
CTar    1134
Quote:
Original post by Hypherion
the error is in the title of the topic... and it's a compilation one.

it's weird because the ide (eclipse) shows me the error on the line where the paranthesis
( "{" ) starts, right after declaring the parameters.


But what does it actually say? Missing semicolon? Unknown type? Something else?

Share this post


Link to post
Share on other sites
Omid Ghavami    1007

You haven't specified a return type for your method in the implementation shown. What return type did you specify when declaring the method in the header?


EDIT: Nevermind, it's the constructor I see know ^^

Share this post


Link to post
Share on other sites
Hypherion    140
"error: return type specification for constructor invalid" -> this is the other error i get and they both redirect me one to the other :| .

Share this post


Link to post
Share on other sites
Omid Ghavami    1007
Quote:
Original post by Hypherion
"error: return type specification for constructor invalid" -> this is the other error i get and they both redirect me one to the other :| .


Can you show us the code where you declare the constructor in the header?

Share this post


Link to post
Share on other sites
rip-off    10976
Quote:
Original post by rip-off
That error is typically caused by forgetting a semicolon at the end of a class / struct / union...


I think you'll find this is the answer. Try adding a semicolon to the end of your SDLCharacter class:


class SDLCharacter
{
public:
SDLCharacter(...);
void foo();
void bar();
}; // <--- HERE

Share this post


Link to post
Share on other sites
CTar    1134
It sounds like you forgot a semicolon after a class declaration (like rip-off said), the compiler then thinks the class is the return type. Anyway if you have a class declaration right before the constructor make sure there is a semicolon, if you have an include directive (#include) before the constructor check if a class in the included file is missing a semicolon.

Share this post


Link to post
Share on other sites
Hypherion    140
argh... this is incredible... *bashes head against nearest wall*
yea, that was it.

Thanks for the help and sorry for the stupid question :| .

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this