EDITED BELOW FOR UPDATES!!! Thank you for the help, please by all means point out ALL mistakes , I don't care if it sounds rude or mean or whatever, emo junk. Just give it to me straight so I can understand what is going wrong.
Hi everyone!
I am a rookie C++ programmer trying to learn and gain some IRL exp for C++.
I am attempting the following inside my VC++ (vs2008) compiler:
typedef unsigned short USHORT;
class Grid
{
...
public:
Grid()
{
Tile[36]* tileList_ptr;
}
...
};
In essence, I want to put 36 tiles , slam them into an array nice and tidy on the heap for a 8x8 playfield that never changes in size. Like a chessboard. Refer to them with a pointer, and fiddle with them in the related cpp file if needed.
If you aren't laughing by now at this attempt then I probably made a syntax error instead of major design flaw :P
Any help would be much appreciated!
Thanks in advance
EDIT 24/08/2010 13:49 (Time of start)
My code is now as following example:
The Grid Header file Grid.h:
#include "Tile.h"
class Grid
{
//no more typedef used
public:
Tile grid[8][8];
private:
unsigned short selectedItemIndexValue;
public:
Grid()
{
Initialize();
}
~Grid(){}
void Update();
void FinalizeMove(unsigned short index);
void Draw();
private:
void Initialize(); //Initializes members
};
The Grid.cpp file:
#include "stdafx.h"
#include "Grid.h"
//Not tile , that used to give me a class redefinition error
unsigned short selectedItemIndexValue;
//No more typedef used
void Grid::Update()
{
//Respond to controller commands
}
void Grid::FinalizeMove(unsigned short index)
{
}
void Grid::Draw()
{
}
void Grid::Initialize()
{
for(int i = 0; i < 4; i++)
{
Grid::grid[i] = new Tile::Tile(10,10); // ATTEMPT AT FILLING ARRAY
}
}
Tile.h file
class Tile
{
public:
private:
enum TileOccupation
{
EmptyTile = 0,
WhiteSphere = 1,
BlackSphere = 2
};
unsigned short horizontalDimensions;
unsigned short verticalDimensions;
public:
Tile(){}
~Tile(){}
void Update();
void Draw();
};
Tile.cpp file:
#include "stdafx.h"
#include "Tile.h"
void Tile::Update()
{
}
void Tile::Draw()
{
}
The attempt at filling the array in Grid.cpp is returning via the compiler the following error message: "Error 1 error C2061: syntax error : identifier '{ctor}'"
MSDN helped me giving me this:
"Compiler Error C2061. The compiler found an identifier where it wasn't expected. Make sure that identifier is declared before you use it."
I have failed at analysing it's meaning. What exactly have I done wrong here ? And what other problems are there to be found in my project? All help and comments will be much appreciated. Just assume I know 0% of C++