undefined reference to add(int x, int y) ???

undefined reference while trying to forward declear a function (add int x , int y ).... please help , thanks
compiler is dev c++

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
39
40
41
42
43
44
45
46
47
#include <cstdlib>
#include <iostream>
#include "conio.h"
#include "math.h"

   int add (int x, int y);
float adx(float a ,float b)
{
return a+b;
}
double sqt(float c,float d)
{
  return pow(c,d);
}
int main(int argc, char *argv[])
{
 
    float a;
    float c;
    float d;
    float b;
    
    using namespace std;
    
    cout << "two values" <<  add(3,4) << endl;
    
    cout << "enter value of a" << endl;
    cin >> a;
    
    cout << "enter value of b" << endl;
    cin >> b;
    
    cout << "enter another value" << endl;
    cin >> c;
    
    cout << "enter another value" << endl;
    cin >> d;
    
    cout << "square root of last two values is" << sqt(c,d) << endl;
    
    cout << "sum of first two values is" << adx(a,b) << endl;
    cin.get();
    
    cin.get();
    return EXIT_SUCCESS;
}
Where is there the function definition?! Or you think the compiler shall invent it itself instead of you?
The linker can't find the definition of add. Where is it?
is it the " int add (int x, int y);" line?
No that's a declaration. The definition is where you write what the function should do.
...... how to change it
What are you going to change?! You have to define this function. Nobody knows what it should do except you.
it adds 3 and 4
Maybe. I do not know beacuse neither me nor the compiler see the function definition.
Stop bla, bla, bla. Define the function!
Last edited on
look at lines 7-10 to how define a function
thanks , it finally worked
Topic archived. No new replies allowed.