Jump to content
  • Advertisement
Sign in to follow this  
_Sauce_

Classes Issue

This topic is 4439 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working with MVC++ 2005 Express Edition, and am getting the error C2533 when I try to compile the code.
------ Build started: Project: BiggerFish, Configuration: Release Win32 ------
Compiling...
Fish.cpp
.\Fish.cpp(11) : error C2533: 'Fish::{ctor}' : constructors not allowed a return type
Build log was saved at "file://c:\Documents and Settings\Hillam\My Documents\Visual Studio 2005\Projects\BiggerFish\BiggerFish\Release\BuildLog.htm"
BiggerFish - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
When I typed C2533 in the help files, it told me this: int X::X() { } //C2533. X::X() { } //OK. The problem is that I haven't specified a return balue for this function, so why is it telling me I'm not allowed to? Here is my class, Fish.cpp (Fish.h is somewhere else, and DOES exist, so don't tell me that is the problem):
////////////////////////////////////////////////
// Fish()
////////////////////////////////////////////////
Fish::Fish(void)
{
	i_Level = 0;
	i_Exp = 0;
	i_MoveSpeed = 0;
	c_MoveDirection;
	b_IsBubble = FALSE;
}

////////////////////////////////////////////////
// ~Fish()
////////////////////////////////////////////////
Fish::~Fish(void)
{
}

Share this post


Link to post
Share on other sites
Advertisement
My guess: You have a malformed statement right BEFORE the constructor. Like, perhaps near the end of a header file included by the source file which defines the constructor. Like, perhaps you've left the semicolon off the end of a class definition? For instance, the definition of the Fish class? HMMMM?


When confronted with an error message that seems incorrect, always consider the lines before the line causing the error. After all, C/C++ really has no concept of "lines", just of statements. Unterminated things can make a "line" quite long.

Share this post


Link to post
Share on other sites
Well, I'm pretty sure it ISN't the header file because it was working fine but I accidentally deleted the Fish.cpp that went with it, and as a result, had to rewrite it. Nevertheless, I'll try posting the Fish.h file as well.

Share this post


Link to post
Share on other sites
Also you don't have to declare a "void" parameter list in C++, and actually it is encouraged not to put it.

Share this post


Link to post
Share on other sites
Here is the build log:


------ Build started: Project: BiggerFish, Configuration: Release Win32 ------
Compiling...
Fish.cpp
.\Fish.cpp(11) : error C2533: 'Fish::{ctor}' : constructors not allowed a return type
Build log was saved at "file://c:\Documents and Settings\Hillam\My Documents\Visual Studio 2005\Projects\BiggerFish\BiggerFish\Release\BuildLog.htm"
BiggerFish - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Fish.cpp:


////////////////////////////////////////////////
// Fish.cpp
////////////////////////////////////////////////

#include "Fish.h"

////////////////////////////////////////////////
// Fish()
////////////////////////////////////////////////
Fish::Fish(void)
{
i_Level = 0;
i_Exp = 0;
i_MoveSpeed = 0;
c_MoveDirection;
b_IsBubble = FALSE;
}

////////////////////////////////////////////////
// ~Fish()
////////////////////////////////////////////////
Fish::~Fish(void)
{
}

////////////////////////////////////////////////
// SetLevel()
////////////////////////////////////////////////
void Fish::SetLevel(int Level)
{
i_Level = Level;
}

////////////////////////////////////////////////
// GetLevel()
////////////////////////////////////////////////
int Fish::GetLevel()
{
return i_Level;
}

///////////////////////////////////////////////
// SetExp()
///////////////////////////////////////////////
void Fish::SetExp(int Exp)
{
i_Exp = Exp;
}

///////////////////////////////////////////////
// GetExp()
///////////////////////////////////////////////
int Fish::GetExp()
{
return i_Exp;
}

///////////////////////////////////////////////
// SetMoveSpeed()
///////////////////////////////////////////////
void Fish::SetMoveSpeed(int MoveSpeed)
{
i_MoveSpeed = MoveSpeed;
}

///////////////////////////////////////////////
// GetMoveSpeed()
///////////////////////////////////////////////
int Fish::GetMoveSpeed()
{
return i_MoveSpeed;
}

///////////////////////////////////////////////
// SetMoveDirection()
///////////////////////////////////////////////
void Fish::SetMoveDirection(char MoveDirection)
{
c_MoveDirection = MoveDirection;
}

///////////////////////////////////////////////
// GetMoveDirection()
///////////////////////////////////////////////
char Fish::GetMoveDirection()
{
return c_MoveDirection;
}

///////////////////////////////////////////////
// SetIsBubble()
///////////////////////////////////////////////
void Fish::SetIsBubble(bool IsBubble)
{
b_IsBubble = IsBubble;
}

///////////////////////////////////////////////
// GetIsBubble()
///////////////////////////////////////////////
bool Fish::GetIsBubble()
{
return b_IsBubble;
}

///////////////////////////////////////////////
// SetLocationX()
///////////////////////////////////////////////
void Fish::SetLocationX(int LocationX)
{
i_LocationX = LocationX;
}

///////////////////////////////////////////////
// GetLocationX()
///////////////////////////////////////////////
int Fish::GetLocationX()
{
return i_LocationX;
}

///////////////////////////////////////////////
// SetLocationY()
///////////////////////////////////////////////
void Fish::SetLocationY(int LocationY)
{
i_LocationY = LocationY;
}

///////////////////////////////////////////////
// GetLocationY()
///////////////////////////////////////////////
int Fish::GetLocationY()
{
return i_LocationY;
}



And Fish.h:


/////////////////////////////////////////////////////////////
// Fish.h
/////////////////////////////////////////////////////////////

#pragma once

#include <windows.h>

class Fish
{
protected:
int i_Level;
int i_Exp;
int i_MoveSpeed;
char c_MoveDirection;
bool b_IsBubble;
int i_LocationX;
int i_LocationY;

public:
Fish(void);
~Fish(void);

void SetLevel(int Level);
int GetLevel();
void SetExp(int Exp);
int GetExp();
void SetMoveSpeed(int MoveSpeed);
int GetMoveSpeed();
void SetMoveDirection(char MoveDirection);
char GetMoveDirection();
void SetIsBubble(bool IsBubble);
bool GetIsBubble();
void SetLocationX(int LocationX);
int GetLocationX();
void SetLocationY(int LocationY);
int GetLocationY();
}

Share this post


Link to post
Share on other sites
...


Did you even read my first post? You know, the one where I correctly diagnosed the problem before you'd even posted the code, by reading your mind?

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
...


Did you even read my first post? You know, the one where I correctly diagnosed the problem before you'd even posted the code, by reading your mind?


Of course I read it! I just went through my code though and couldn't find any errors in the .h file so I posted everything to see if one of you guys could find it. Also, I added that ; after declaring the class (I thought that was illegal!) and guess what? 30 more errors pop up, so I'll have a look at those if it is legal to put the semicolon where you said.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!