[Linker error] undefined reference to `doSomething(int*, int*)'

Hey!

I am currently writing a program for a homework assignment, but I seem to be encountering an error. The question asks:

The following function uses reference variables as parameters. Rewrite the function so it uses pointers instead of reference variables, and then demonstrate the function in a complete program.

int doSomething(int &x, int &y)
{
int temp =x;
x = y * 10;
y = temp * 10;
return x + y;
}

I understand how to covert the reference variables to pointers, however I am stuck on this error. Either I get the error listed in the title or (with a few changes) the error "invalid conversion from 'int' to 'int*'"

What am I doing incorrectly?

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
34
35
36
37
#include <iostream>
using namespace std;

int doSomething(int*, int*);

int main()
{
    int X, Y, result;
    
    int* ptr_x = X;
    int* ptr_y = Y;
    
    cout << "What is your value for x?\nIntegers only.\n";
    cin >> *ptr_x;
    
    cout << "What is your value for y?\nIntegers only.\n";
    cin >> *ptr_y;
    
    cout << "Now I will do something to the numbers!\n";
    
    result = doSomething(ptr_x, ptr_y);
    
    cout << "I have multiplied both x and y by 10 and then added them together!\nHere is the result " //I really didn't know how else to use the "doSomething" function in a meaningful way.  So... I just stated what the function does.  
    << result << ".\n";
    
    system("PAUSE");
    return 0;
    
}

int doSomthing(int *x, int *y) 
{
    int temp = *x;
    *x = *y * 10;
    *y = temp * 10;
    return *x + *y;
}


Thank you!
closed account (zb0S216C)
These two do not correspond:

1
2
int doSomething(int*, int*);
int doSomthing(int *x, int *y)

There's a spelling error in "Something". To the compiler, the two functions are completely different from each other.

Wazzak
Last edited on
Topic archived. No new replies allowed.