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

Started by
10 comments, last by Hypherion 17 years, 11 months ago
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
Advertisement
What error do you get, and on which line? Is it a runtime or compilation error?
That error is typically caused by forgetting a semicolon at the end of a class / struct / union...
In Compile time (somewhat a stupid question)? What line does the error point to?

EDIT: Ow. Beat by two people in under a minute.
Projects:> Thacmus - CMS (PHP 5, MySQL)Paused:> dgi> MegaMan X Crossfire
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
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?

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
"error: return type specification for constructor invalid" -> this is the other error i get and they both redirect me one to the other :| .
"Try not to become a man of success but rather to become a man of value." - Albert Einstein
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
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 

This topic is closed to new replies.

Advertisement