Here is the error
Here's the sources:
cLevel.h
cTile.h
If I remove the cLevel constructor (which I need) the error disappears and compiles perfectly.
Code:
cLevel.h:19: error: no matching function for call to 'cTile::cTile()'
cTile.h:21: note: candidates are: cTile::cTile(SDL_Surface*, int, int, int)
cTile.h:8: note: cTile::cTile(const cTile&)
Here's the sources:
cLevel.h
Code:
//Shawn Barnes
//June 3rd, 2006
#ifndef __CLEVEL_H_
#define __CLEVEL_H_
#include <iostream.h>
#include <fstream.h>
#include "cTile.h"
class cLevel {
private:
SDL_Surface* m_Bitmap;
SDL_Surface* m_Window;
cTile m_Tiles[WTILE_HEIGHT][WTILE_WIDTH];
public:
cLevel(SDL_Surface* window, SDL_Surface* lBitmap)
{
m_Window = window;
m_Bitmap = lBitmap;
Load("data/test.txt");
}
~cLevel() { }
//asdf
void Load(char* level)
{
ifstream input_stream(level);
int dummy[3];
int input_tile_type;
input_stream >> dummy[0];
input_stream >> dummy[1];
input_stream >> dummy[2];
for(int col = 0; col < WTILE_HEIGHT; col++)
{
for(int row = 0; row < WTILE_WIDTH; row++)
{
input_stream >> input_tile_type;
m_Tiles[col][row] = cTile(m_Bitmap, row*TILE_WIDTH, col*TILE_HEIGHT, (int)input_tile_type);
}
}
}
void Draw()
{
for(int col = 0; col < WTILE_HEIGHT; col++)
{
for(int row = 0; row < WTILE_WIDTH; row++)
{
m_Tiles[col][row].Draw(m_Window);
}
}
}
};
#endif
cTile.h
Code:
//cTile by Shawn Barnes
//Date: June 3rd, 2006
//Thanks for Aaron Cox for the help
#ifndef __CTILE_H_
#define __CTILE_H_
class cTile {
private:
int m_ImageX;
int m_ImageY;
int m_Width;
int m_Height;
int m_Type;
int dstX;
int dstY;
SDL_Surface* m_Tile;
public:
cTile(SDL_Surface* bitmap, int dx, int dy, int type) :
m_Tile(bitmap), dstX(dx), dstY(dy), m_Type(type)
{
SDL_Rect r = TileTypeRect(type);
m_ImageX = r.x;
m_ImageY = r.y;
m_Width = r.w;
m_Height = r.h;
m_Type = type;
m_Tile = bitmap;
}
~cTile()
{
SDL_FreeSurface(m_Tile);
}
SDL_Rect TileTypeRect(int type)
{
SDL_Rect tile_rect;
switch(type)
{
case 1:
tile_rect.x = 0;
tile_rect.y = 0;
tile_rect.w = 32;
tile_rect.h = 32;
break;
default:
break;
}
return tile_rect;
}
int GetType()
{
return m_Type;
}
void SetImageLocation(int x, int y)
{
m_ImageX = x;
m_ImageY = y;
}
void Draw(SDL_Surface* window)
{
SDL_Rect source = { m_ImageX, m_ImageY, m_Width, m_Height };
SDL_Rect destination = { dstX, dstY, m_Width, m_Height };
SDL_BlitSurface(m_Tile, &source, window, &destination);
}
};
#endif
If I remove the cLevel constructor (which I need) the error disappears and compiles perfectly.