This has gotta be one of the most $%^$% errors ever:
Quote:Error 1 error C2514: 'Tile' : class has no constructors c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 47
Can anyone tell me why it's happening? The code is C++ obviously and I'm using VS2005 version 8 with the standard compiler (whatever that is).
Here's my Level ctor:
Level::Level(std::string n,
ushort size_w,
ushort size_h,
ushort cam_x,
ushort cam_y,
ushort cam_w,
ushort cam_h)
:
name(n)
{
size.w = size_w;
size.h = size_h;
camera.x = cam_x;
camera.y = cam_y;
camera.w = cam_w;
camera.h = cam_h;
/* Initialise tiles. */
tiles.resize(size_h);
SDL_Rect clip;
ushort tile_no = 0;
std::string name = "";
for(ushort i = 0; i < size_h; ++i)
{
for(ushort j = 0; i < size_w; ++j, ++tile_no)
{
clip.x = j * TILE_WIDTH + TILE_BORDER;
clip.y = i * TILE_HEIGHT + TILE_BORDER;
clip.w = TILE_WIDTH;
clip.h = TILE_HEIGHT;
if(tile_no >= 10)
name = "T_0" + ToString(tile_no);
else
name = "T_00" + ToString(tile_no);
tiles.push_back(Tile(name,
"",
INVISIBLE,
AC_NOTHING,
j * TILE_WIDTH,
i * TILE_HEIGHT,
clip));// Error is here
}
}
}
Level.h file:
// Checkers
// Created by Mitch Curtis, 2007
#ifndef IMAGE_H
#define IMAGE_H
#include <string>
#include <vector>
#include <iostream>
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "Misc.h"
#include "Draw_Engine.h"
#include "Timer.h"
#include "Image.h"
#include "User_Interface.h"
typedef unsigned short int ushort;
class Tile;
class Level
{
public:
Level(std::string n,
ushort size_w,
ushort size_h,
ushort cam_x,
ushort cam_y,
ushort cam_w,
ushort cam_h);
twodindex Get_Tile_Hit(SDL_Rect mouse);
void Clear_Tiles();
void Apply_Tile_Pen();
void Set_Tile_At(std::string tile, std::string to_this);
void Set_Camera(ushort x, ushort y, ushort w, ushort h);
void Nudge_Camera(DIRECTION dir);
protected:
std::string name;
std::vector<std::vector<Tile> > tiles;
SDL_Rect size;
SDL_Rect camera; // colour key
};
#endif
Tile class:
class Tile : public Image
{
public:
Tile(std::string n,
std::string status_msg,
PRIORITY p,
ACTION_CODE ac,
int x,
int y,
SDL_Rect c,
SDL_Surface* s = NULL);
std::string Get_Name() const;
void Set_Name(std::string new_name);
ACTION_CODE Get_Action_Code() const;
std::string Get_Status_Bar_Msg() const;
private:
std::string name;
ACTION_CODE action_code;
std::string status_bar_msg;
};
Tile ctor:
Tile::Tile(std::string n,
std::string status_msg,
PRIORITY p,
ACTION_CODE ac,
int x,
int y,
SDL_Rect c,
SDL_Surface* s)
:
name(n),
status_bar_msg(status_msg),
action_code(ac)
{
surface = s;
ToClip(clip, c);
info.x = x;
info.y = y;
info.w = TILE_WIDTH;
info.h = TILE_HEIGHT;
priority = p;
is_colour_key = true;
is_clip = true;
}
I'm posting so much code just in case someone asks for it.. and 'cause I'm el stupido when it comes to forward declarations and that $#^#.
Edit: Oh yeah, there's also THESE:
Quote:Error 2 error C2027: use of undefined type 'Tile' c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 61
Error 3 error C2228: left of '.Get_Info' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 61
Error 4 error C2228: left of '.x' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 61
Error 5 error C2027: use of undefined type 'Tile' c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 61
Error 6 error C2228: left of '.Get_Info' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 61
Error 7 error C2228: left of '.x' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 61
Error 8 error C2027: use of undefined type 'Tile' c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 62
Error 9 error C2228: left of '.Get_Info' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 62
Error 10 error C2228: left of '.y' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 62
Error 11 error C2027: use of undefined type 'Tile' c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 62
Error 12 error C2228: left of '.Get_Info' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 62
Error 13 error C2228: left of '.y' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 62
Error 14 error C2027: use of undefined type 'Tile' c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 78
Error 15 error C2228: left of '.Set_Name' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 78
Error 16 error C2027: use of undefined type 'Tile' c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 89
Error 17 error C2228: left of '.Get_Name' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 89
Error 18 error C2027: use of undefined type 'Tile' c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 90
Error 19 error C2228: left of '.Set_Name' must have class/struct/union c:\documents and settings\user\my documents\visual studio 2005\projects\hex\earth\earth\level.cpp 90
Which I'm guessing are a result of the first error. Sorry about all the code once again. :)