undefined reference to `function name'
Oct 7, 2018 at 5:44am UTC
i write a function, the purpose is to get the positive number, even if the value is smaller than zero
but i get an error, 0.cpp:(.text+0x12b): undefined reference to `absolute(int)'.
this is my program:
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 38
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int absolute(int );
int main(){
int n;
cin >> n;
string *data = new string[n];
for (int i = 0; i < n; i++){
cin >> *(data+i);
}
for (int i = 0; i < n; i++){
int number = absolute((*(data+i))[0] - (*(data+i))[n-1]);
for (int j = 0; j < n / 2 + 1; j++){
if (absolute((*(data+i))[j] - (*(data+i))[n-1-j]) != number){
cout << "Not Funny" << endl;
break ;
}else if (j == n / 2){
cout << "Funny" << endl;
}
}
}
system("pause" );
return 0;
}
int abosolute(int one){
int number = one;
if (number >= 0){
return number;
}else {
return number * -1;
}
return -1;
}
this is error message:
0.cpp:(.text+0x12b): undefined reference to `absolute(int)'
0.cpp:(.text+0x19b): undefined reference to `absolute(int)'
please tell me what happened and how to fix it.
Last edited on Oct 7, 2018 at 6:03am UTC
Oct 7, 2018 at 5:51am UTC
Have a VERY close look at line 30. You can't spell.
Oct 7, 2018 at 6:04am UTC
What is that means? And how to fix it?
Oct 7, 2018 at 6:09am UTC
i know what wrong is thanks
Last edited on Oct 7, 2018 at 7:16am UTC
Topic archived. No new replies allowed.