illegal function overloading????

This is a discussion on illegal function overloading???? within the C++ Programming forums, part of the General Programming Boards category; You don't need to know excactly what's going in to figure out what's wrong, so I'll skip the explanation, but ...

  1. #1
    Registered User Mr_Jack's Avatar
    Join Date
    Oct 2003
    Posts
    63

    illegal function overloading????

    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

  2. #2
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    When you get an illegal function overloading error its always a good idea to check the function declaration and definition to make sure they match.

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    ...


    Your function declarations say net* while your definitions say node*, or vice versa.

  4. #4
    Registered User Mr_Jack's Avatar
    Join Date
    Oct 2003
    Posts
    63
    thanks for your help, I can't believe that I didn't catch that

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 12:49 PM
  2. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 06:18 AM
  3. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  4. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21