Skip to main content
GameDev.net gamedev.net
🔒 Locked

Illegal use of type 'void'

Started by JonathanO'Brien Jun 22, 2011 at 6:35 AM 4 replies 11.8k views
Original Post
JonathanO'Brien
JonathanO'Brien
This error honestly makes no sense and is best explained by the code and compiler output.

When I code:


#ifndef CLASSES_H
#define CLASSES_H

#include "SDL.h"

class Player
{
private:
//position and velocity variables
SDL_Rect playerBox;
int xVel, yVel;
//animation frame
int frame;

public:
//basic functions
void handle_input;
void move;
void render;
};

#endif


The compiler returns:


error C2182: 'handle_input' : illegal use of type 'void'
error C2182: 'move' : illegal use of type 'void'
error C2182: 'render' : illegal use of type 'void'


Thanks and I hope that you guys can help with this most peculiar error.
-A1P4A 0M3GA
Lead script writer on Scutum [http://www.gamedev.n...-entertainment/]
Team Member of [size=2]Forcas Entertainment
Amateur programmer with C++ and SDL knowledge
Game Enthusiast
GregMichael
GregMichael
Try this...

public:
void handle_input();
void move();
void render();
ArthY303
ArthY303
Hello!

public:
//basic functions
void handle_input;
void move;
void render;

These are supposed to be functions. However, you don't specify their prototypes completely. You need to add the parameter list. If the functions
don't have parameters, just add empty parentheses.

Like so:

public:
//basic functions
void handle_input();
void move();
void render();


JonathanO'Brien
JonathanO'Brien
0.0 Holy crap, I can't believe I did that. Sorry to waste your time...
-A1P4A 0M3GA
Lead script writer on Scutum [http://www.gamedev.n...-entertainment/]
Team Member of [size=2]Forcas Entertainment
Amateur programmer with C++ and SDL knowledge
Game Enthusiast
rip-off
rip-off
If you had Googled the error code C2182, you would see that the compiler thinks you are declaring variables of type void. The compiler error message is a little poor, but then again they often are.
JonathanO'Brien
JonathanO'Brien

If you had Googled the error code C2182, you would see that the compiler thinks you are declaring variables of type void. The compiler error message is a little poor, but then again they often are.


Thanks, I'll remember to google the error code rather than the text attached for future reference.
-A1P4A 0M3GA
Lead script writer on Scutum [http://www.gamedev.n...-entertainment/]
Team Member of [size=2]Forcas Entertainment
Amateur programmer with C++ and SDL knowledge
Game Enthusiast

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.