Undeclared function?

Jan 8, 2009 at 1:20am
I'm getting an error saying 'not_equal_to undeclared. First use this function.'
but not_equal_to is not a variable its a function. and it is defined directly above it, outside any other function. Why am I getting this error? I'm trying to read the output of my not_equal_to function using this statement:

1
2
     	if ( not_equal_to(__a,i) == 0 )
      		continue;


and directly above this function i have it defined:

1
2
3
4
5
6
7
8
9
10
11
int not_equal_to(int _h, int value)
{
    int result;
    result=1;
    for (int u=0;u<_h;u++)
    {
    if (value=point[u])
    result=0;
    }
    return result;
}


This is really confusing me. What is going on?
Jan 8, 2009 at 1:22am
Can you give us more of the code, doesn't seem to be any obvious errors in what you've posted.
Jan 8, 2009 at 1:30am
the exact code fragment below.
i have no idea why it is giving me errors.
in line 18 it says not_equal_to is undeclared (first use this function)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
int not_equal_to(int _h, int value)
{
    int result;
    result=1;
    for (int u=0;u<_h;u++)
    {
    if (value=point[u])
    result=0;
    }
    return result;
}

int closest_point (int __a)
{
         int find_closest_to=__a;
     int closest=-1;
     for (int i=0;i<amm;i++){
     	if ( not_equal_to(__a,i) == 0 )
      		continue;
    	if (closest<0 || find_distance(closest,point[find_closest_to])>find_distance(i,point[find_closest_to]))
     		closest=i;
       }
       if (closest<0)
           {
       	   cout << "Error occured in locating points.";
           }
     return closest;
}
Last edited on Jan 8, 2009 at 1:31am
Jan 8, 2009 at 1:33am
Line 7: Where is point declared?
and it should be ==, not =
Last edited on Jan 8, 2009 at 1:34am
Jan 8, 2009 at 1:48am
that was only a fragment of the code, point was defined higher up.
but it still returned the error
but i fixed it by changing the name of the function to not_e_to.
is not_equal_to a pre-defined constant or something?
Jan 8, 2009 at 1:51am
it could already be declared in a header you have imported.
Jan 8, 2009 at 2:45am
thanks that worked, but now i have a bigger problem that can't be resolved without seeing the whole code and knowing what the purpose of the code is.
the whole thing is 158 lines so far, would i be able to post it all here or is that too much code for someone here to spend time looking at?
Jan 8, 2009 at 10:41am
No-one will be able to help if they can't see the problem.
As long as it doesn't overstep the character boundaries and its nicely formatted its not too much for anyone to go through and read.
Jan 8, 2009 at 10:41am
No-one will be able to help if they can't see the problem.
As long as it doesn't overstep the character boundaries and its nicely formatted its not too much for anyone to go through and read, be sure to post what errors pop up and which lines they point to
Topic archived. No new replies allowed.