Help: Problem with SDL code

S

SpiralCorp

The code: http://pastebin.ca/481492

I'm having a problem in line 128. Right as the sprite class
constructor begins. The compiler spits this at me:
"Return type specification for constructor invalid
New types may not be defined in a return type"

******************
class sprite
{
private:
int x, y, xvel, yvel, phase; //Determines sprite position
offsets and velocity

public:
sprite(); //Constructor
void handle_input();
void move ();
void show ();
}

sprite::sprite()
{
//Initialize offsets and velocity
x = 25;
y = 385;
xvel = 0;
yvel = 0;
phase = 0;
}
*********************
As you can see I'm not defining anything. I have no idea whats wrong
here, the problem must be somewhere else in the code? I'm lost here.

Yes, there are other errors but I need to get past this one first and
yes the code is not quite complete but still, what the hell is up with
this one?
 
V

Victor Bazarov

SpiralCorp said:
The code: http://pastebin.ca/481492

I'm having a problem in line 128. Right as the sprite class
constructor begins. The compiler spits this at me:
"Return type specification for constructor invalid
New types may not be defined in a return type"

******************
class sprite
{
private:
int x, y, xvel, yvel, phase; //Determines sprite position
offsets and velocity

public:
sprite(); //Constructor
void handle_input();
void move ();
void show ();
}

You forgot the semicolon here.
sprite::sprite()
{
//Initialize offsets and velocity
x = 25;
y = 385;
xvel = 0;
yvel = 0;
phase = 0;
}
*********************
As you can see I'm not defining anything. I have no idea whats wrong
here, the problem must be somewhere else in the code? I'm lost here.

Yes, there are other errors but I need to get past this one first and
yes the code is not quite complete but still, what the hell is up with
this one?

V
 
S

SpiralCorp

You forgot the semicolon here.







V

Thanks, that cleared up the class issue. Now ofcourse, I have more
problems... and all escape me. I really hope the new ones aren't as
embarrasing >_>

Heres the new code: http://pastebin.ca/481617

Problem 1:
Line 166 expected primary-expression before ',' token

Problem 2:
Line 206 expected `;' before "guysprite"

Ideas? =/

Thanks for the help, guys.
 
V

Victor Bazarov

SpiralCorp said:
[..]
Thanks, that cleared up the class issue. Now ofcourse, I have more
problems... and all escape me. I really hope the new ones aren't as
embarrasing >_>

Heres the new code: http://pastebin.ca/481617

Problem 1:
Line 166 expected primary-expression before ',' token

You're trying to call a function. What's the third argument? What
did you intend it to be?
Problem 2:
Line 206 expected `;' before "guysprite"

Apparently it doesn't accept 'sprite' as a type-id. Perhaps it got
confused earlier.
Ideas? =/

None, really.

V
 
S

SpiralCorp

SpiralCorp said:
[..]
Thanks, that cleared up the class issue. Now ofcourse, I have more
problems... and all escape me. I really hope the new ones aren't as
embarrasing >_>
Problem 1:
Line 166 expected primary-expression before ',' token

You're trying to call a function. What's the third argument? What
did you intend it to be?
Problem 2:
Line 206 expected `;' before "guysprite"

Apparently it doesn't accept 'sprite' as a type-id. Perhaps it got
confused earlier.
Ideas? =/

None, really.

V

Well, I figured it out a while ago. Forgot to check back here. Turns
out the compiler took issue with me using "sprite" as both a class AND
a surface variable. Thats what I get for recycling code. I've
restarted the whole thing, maybe I'll be back here with more newbie
mistakes in the near future =/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top