Undefined Reference

Hello guys.
I'm doing a practical work and i had to make a shorter path algorithm.

I coded everything but i get this error: undefined reference to `calcular_distancia(int&, int&, bool (*) [10], int&, bool*)'

I can't seem to notice what is wrong with this.
Here is the code so you can see it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  
int calcular_distancia(int& a, int& b, bool M[][10], int& c, bool visita[10]);
void duplicar_vector(bool a[], bool b[], int tamanio);
void crear_matriz(bool a[][10]);
int minimo(int a[], int tamanio);

int main()
{
    bool M[10][10];                                 // DeclaraciĆ³n de matriz adyacencia
    bool visita[10];                                // Matriz para saber si un nodo fue visitado
    int cont = 1;                                   // Contador de distancia
    crear_matriz(M);
    int a = 0;
    int b = 9;
    cout << calcular_distancia(a, b, M, cont, visita);
    
    return 0;
}


And here is the function it has troubles with:

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
29
30
31
int calcular_distancia(int& a, int& b, int M[][10], int& c, bool visita[10])
{
    if (a == b)
    {
        return 0;
    }

    if(M[a][b])
    {
        return c;
    }
    else c++;
    visita[a] = true;                                            // Cambia el estado del nodo a, a visitado
    bool visita2[10];
    duplicar_vector(visita, visita2, 10);
    int distancias[10];
    int contador = c;

    int i;
    for(i=0; i<=9; i++)
    {
        c = contador;
        if((M[a][i] == true) && (visita[i] = false))
        {
            distancias[i] = calcular_distancia(i, b, M, c, visita2);
        }
    }

    return minimo(distancias, 10);

}


The function is probably wrong (both in code and what it should do).

Well, that's all. Thanks for your help!

PD: The code is in Spanish, hope it doesn't make it harder to read. I'm from Argentina :P
Last edited on
My favorite game: Spot the difference.
1
2
int calcular_distancia(int& a, int& b, bool M[][10], int& c, bool visita[10]);
int calcular_distancia(int& a, int& b, int  M[][10], int& c, bool visita[10])


Declaration and definition should be same. If you change one, copy-past whole line into other.
OMG, i can't believe i'm so stupid. Thank you for your help.

BTW, the code didn't work (obviously), so i'll have to see what's wrong.

Thanks again!
Topic archived. No new replies allowed.