Hi everyone! Rookie C++ Programmer here again
I'm using VC++ VS2008 and making an attempt at creating an array of arrays. All objects I wish to store I want to put on the heap.
In the arrays it's all just pointers.
Here's some code:
Grid.h
#include "Tile.h"
class Grid
{
public:
Tile* grid_ptr[8][8];
...
...
};
Grid.cpp
#include "stdafx.h"
#include "Grid.h"
...
...
void Grid::Initialize()
{
for(int i = 0; i < 8; i++)
{
Grid::grid_ptr[i][0] = new Tile::Tile(10,10);
for (int j = 0; j < 8; j++)
{
Grid::grid_ptr[i][j] = new Tile::Tile(10,10);
}
}
}
...
...
}
Everything works just fine including the tile construction. It seems like a syntax error seeing as the compiler gives me this
Error 1 error C2061: syntax error : identifier '{ctor}'
Error 2 error C2061: syntax error : identifier '{ctor}'
All the time the same story. This has my entire work bogged down to a halt unfortunatly and I would MUCH Appreciate a solution to this.
In short. How do I properly create an array of arrays 8x8 in size filled with pointers referencing their respective tile objects ?
Is this even possible or smart to do using memory like that?
mind that I did read lots of examples on this, and doing so with integers or other datatypes has been a succes. That however simply isn't want I want allocated
Tile.h here and Tile.cpp below
class Tile
{
public:
private:
enum TileOccupation
{
EmptyTile = 0,
WhiteSphere = 1,
BlackSphere = 2
};
unsigned short horizontalDimensions;
unsigned short verticalDimensions;
public:
Tile();
Tile(unsigned short horizontalDimensions, unsigned short verticalDimensions);
~Tile();
void Update();
void Draw();
};
> Tile.cpp
#include "stdafx.h"
#include "Tile.h"
Tile::Tile()
{
}
Tile::Tile(unsigned short horizontalDimensions, unsigned short verticalDimensions)
{
}
void Tile::Update()
{
}
void Tile::Draw()
{
}