Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 Hypherion   Members   -  Reputation: 140

Like
0Likes
Like

Posted 02 May 2006 - 01:24 AM

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 :)
"Try not to become a man of success but rather to become a man of value." - Albert Einstein

Sponsor:

#2 CTar   Members   -  Reputation: 1134

Like
0Likes
Like

Posted 02 May 2006 - 01:26 AM

What error do you get, and on which line? Is it a runtime or compilation error?

#3 rip-off   Moderators   -  Reputation: 7640

Like
0Likes
Like

Posted 02 May 2006 - 01:26 AM

That error is typically caused by forgetting a semicolon at the end of a class / struct / union...

#4 deadimp   Members   -  Reputation: 310

Like
0Likes
Like

Posted 02 May 2006 - 01:27 AM

In Compile time (somewhat a stupid question)? What line does the error point to?

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

#5 Hypherion   Members   -  Reputation: 140

Like
0Likes
Like

Posted 02 May 2006 - 01:29 AM

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.
"Try not to become a man of success but rather to become a man of value." - Albert Einstein

#6 CTar   Members   -  Reputation: 1134

Like
0Likes
Like

Posted 02 May 2006 - 01:38 AM

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?

#7 Omid Ghavami   Members   -  Reputation: 975

Like
0Likes
Like

Posted 02 May 2006 - 01:40 AM


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 ^^
Best regards, Omid

#8 Hypherion   Members   -  Reputation: 140

Like
0Likes
Like

Posted 02 May 2006 - 01:42 AM

"error: return type specification for constructor invalid" -> this is the other error i get and they both redirect me one to the other :| .

#9 Omid Ghavami   Members   -  Reputation: 975

Like
0Likes
Like

Posted 02 May 2006 - 01:44 AM

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?
Best regards, Omid

#10 rip-off   Moderators   -  Reputation: 7640

Like
0Likes
Like

Posted 02 May 2006 - 01:45 AM

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


#11 CTar   Members   -  Reputation: 1134

Like
0Likes
Like

Posted 02 May 2006 - 01:46 AM

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.

#12 Hypherion   Members   -  Reputation: 140

Like
0Likes
Like

Posted 02 May 2006 - 01:50 AM

argh... this is incredible... *bashes head against nearest wall*
yea, that was it.

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS