class oop_bot
{
private:
int ID;
int x;
int y;
int energy;
char direction;
public:
void oop_bot(int ID, int x, int y, int energy, char direction); //Constructor ALL
void oop_bot(int ID); //Contructor ID
//Getters
int getID();
int getX();
int getY();
int getEnergy();
char getDirection();
//Setters
void setID(int ID);
void setX();
void setY();
void setEnergy();
void setDirection();
//Movement
void Go();
void Turn();
};
void oop_bot::oop_bot(int ID, int x, int y, int energy, char direction)
{
oop_bot::ID = ID;
oop_bot::x = x;
oop_bot::y = y;
oop_bot::energy = energy;
oop_bot::direction = direction;
}
void oop_bot::oop_bot(int ID)
{
oop_bot::ID = ID;
}
I'm getting an error that looks like this:
1 2 3 4
Error 1 error C2380: type(s) preceding 'oop_bot' (constructor with return type, or illegal redefinition of current class-name?) c:\users\dj\documents\visual studio 2008\projects\oop_bot\oop_bot\oop_bot.cpp 16
Error 2 error C2380: type(s) preceding 'oop_bot' (constructor with return type, or illegal redefinition of current class-name?) c:\users\dj\documents\visual studio 2008\projects\oop_bot\oop_bot\oop_bot.cpp 17
Error 3 error C2533: 'oop_bot::{ctor}' : constructors not allowed a return type c:\users\dj\documents\visual studio 2008\projects\oop_bot\oop_bot\oop_bot.cpp 37
Error 4 error C2533: 'oop_bot::{ctor}' : constructors not allowed a return type c:\users\dj\documents\visual studio 2008\projects\oop_bot\oop_bot\oop_bot.cpp 45
Can someone please tell me what exactly I'm doing wrong? I've been trying to debug this for awhile, but I'm getting nowhere. I'd appreciate any help I can get. Thank you!
You are adding return types (void) to your constructors. Constructors don't have return types. Pretty much exactly what the error message is stating: "constructor with return type".