undefined reference

I'm getting the error undefined reference to 'pointerswap(int*, int*)'

How do I fix this? Thank you!

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
32
33
#include <iostream>

using namespace std;

void referenceswap(int &n1, int&n2);
void pointerswap(int * n1ptr, int * n2ptr);
int main()
{
    int num1 = 5, num2 = 10;
    int *num1ptr = &num1;
    int *num2ptr = &num2;

    cout << " original values  :::  " << num1 << " " << num2 << endl;
    referenceswap(num1, num2);
    cout << " values after reference swap ::: " << num1 << " " << num2 << endl;
    pointerswap (num1ptr, num2ptr);
    cout << " values after pointer swap ::: " << num1 << " " << num2 << endl << endl;
    return 0;
}
void referenceswap(int &n1, int&n2)
{
    int temp = n1;
    n1 = n2;
    n2 = temp;
}
void pointerswap (int *&num1, int *&num2)
{
    int  temp = *num1;

        *num1 = *num2;
        *num2 = temp;
}
1
2
void pointerswap(int * n1ptr, int * n2ptr); //line 6, declaration
void pointerswap (int *&num1, int *&num2) //line 26, definition 
¿do you spot the difference?
(Hint: the name of the variables is irrelevant)
Thanks!
Topic archived. No new replies allowed.