You don't need to know excactly what's going in to figure out what's wrong, so I'll skip the explanation, but you may want to know that this is a header file used by my "games".
I get the error "illegal function overloading" where the definitions of function 'createNet' and function 'findPoint'. They don't even have the same signatures... I think my compiler has gone mad. Please tell me if you find anything wrong...
This is the code for my header file:
Code:
#ifndef net_h
#define net_h
struct netInfo
{
int height;
int width;
};
struct node
{
netInfo * pInfo;
int x;
int y;
bool error;
node * up;
node * down;
node * right;
node * left;
node * rowHead;
node * diagUpRight;
node * diagUpLeft;
node * diagDownRight;
node * diagDownLeft;
node() : error(0), up(0), down(0), right(0), left(0), diagUpRight(0), diagUpLeft(0), diagDownRight(0), diagDownLeft(0) {}
};
struct net
{
netInfo * pInfo;
node * origin;
};
//net creation functions
node * createNet(int, int);
void findUp(node*);
void findDiagUpRight(node*);
void findDiagUpLeft(node*);
//searching functions
net * findPoint(net*, int, int);
/********************************************/
//creation functions
net * createNet(int width, int height)
{
node * current;
node * vertListHead = new node;
netInfo * info = new netInfo;
info->width = width;
info->height = height;
current = vertListHead;
for(int i = 0; i < height; i++)
{
current->pInfo = info;
current->y = i;
current->x = 0;
current->up = new node;
current->up->down = current;
current = current->up;
}
current = vertListHead;
node * horCurrent;
for(int i = 0; i < height; i++)
{
horCurrent = current;
for(int j = 0; j < width; j++)
{
horCurrent->pInfo = info;
horCurrent->rowHead = current;
horCurrent->x = j;
horCurrent->y = i;
horCurrent->right = new node;
horCurrent->right->left = horCurrent;
horCurrent = horCurrent->right;
}
current = current->up;
}
current = vertListHead;
for(int i = 0; i < height; i++)
{
horCurrent = current;
for(int j = 0; j < width; j++)
{
findUp(horCurrent);
findDiagUpRight(horCurrent);
findDiagUpLeft(horCurrent);
if(horCurrent->right != 0)
horCurrent = horCurrent->right;
}
current = current->up;
}
net * newNet = new net;
newNet->origin = vertListHead;
newNet->pInfo = info;
return newNet;
}
void findUp(node * client)
{
node * current;
current = client->rowHead->up;
while(current->x != client->x)
{
if(current->right != 0)
current = current->right;
else
break;
}
client->up = current;
current->down = client;
}
void findDiagUpRight(node * client)
{
node * current;
current = client->rowHead->up;
while(current->x != client->x+1)
{
if(current->right != 0)
current = current->right;
else
break;
}
client->diagUpRight = current;
current->diagDownLeft = client;
}
void findDiagUpLeft(node * client)
{
node * current;
current = client->rowHead->up;
while(current->x != client->x-1)
{
if(current->right != 0)
current = current->right;
else
break;
}
client->diagUpLeft = current;
current->diagDownRight = client;
}
//searching functions
node * findPoint(net * client, int x, int y)
{
int width = client->pInfo->width;
int height = client->pInfo->height;
if((x > width-1) || (y > height-1) || (x < 0) || (y < 0))
{
node * errorNode = new node;
errorNode->error = 1;
return errorNode;
}
node * vertCurrent;
node * horCurrent;
vertCurrent = client->origin;
for(int i = 0; i < height; i++)
{
horCurrent = vertCurrent;
for(int j = 0; j < width; j++)
{
if((horCurrent->x == x) && (horCurrent->y == y))
return horCurrent;
horCurrent = horCurrent->right;
}
vertCurrent = vertCurrent->up;
}
}
#endif