Error in reference of c++

Hey guys,
This is a program to draw a table of conversions from binary to decimal
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iomanip> 
#include <iostream>
#include <string>
using namespace std;
bool checkbinary(long);
int convertBtoD(long); 
void drawline(char);
void header (); 
void body(int, long);
int main()
{
  int n;    // taking inputs
  long A[20];
  cout << "Please enter the number of binary values desired: ";
  cin >> n; 
  while ( (n < 0) || (n > 20) )
  { 
      cout << "ERROR: THE NUMBER ENTERED IS IN-VALID; PLEASE RE-ENTER: ";
      cin >> n; 
      cout << endl; 
  }
  for ( int k = n; k > 0; k--)
  {
      cout << "Please enter the Binary number: ";
      cin >> A[n]; 
      if (!checkbinary(A[n]))
      cout << "ERROR: NUMBER NOT A BINARY NUMBER; PLEASE RE-ENTER: ";
      cin >> A[n]; 
  }
  drawline ('#');
  header(); 
  drawline ('-');
    for (int c = n; c >= 1; c++)
        body(n, A[n]);
  drawline ('#');
  system ("pause");
}
void drawline(char $)
{
    for (int c = 1; c<=30; c++)
    cout << $;
    cout << endl; 
}
void header()
{
    cout << setw(15) << "Binary" << setw(15) << "Decimal" << endl; 
}
void body(int n,long A[20])
{
    for ( int c = n; c > 0; c--)
    cout << setw(15) << A[n] << setw(15) << convertBtoD(A[n]) << endl; 
    return;
}
bool checkbinary(long bin)
{
    int d; 
    while (bin !=0)
    {
        d = bin % 10; 
        bin = bin / 10; 
        if ( (d != 1) || (d !=0) )
        return false;
    }
    return true;
}
int convertBtoD (long num)
{
    int d = 0, w = 1; 
    while (num != 0)
    {
        d = d + (num % 10) + w; 
        num/=10;
        w = w * 2;
    }
    return w; 
}

The output should look like this
####################################
binary decimal
------------------------------------
1101 ..
11111 ...
and so on
####################################
However, I keep receiving this
/tmp/ccsUb3eq.o: In function `main':
:(.text.startup+0x161): undefined reference to `body(int, long)'
collect2: error: ld returned 1 exit status


Any help, please?
Last edited on
void body(int, long) and void body(int, long[20]) are two different functions.

Last edited on
Can I please know how can I make it one function? I want to pass an array
See section "Declaring functions" in http://www.cplusplus.com/doc/tutorial/functions/
how can I make it one function?

By using the same type for all the parameters.
Topic archived. No new replies allowed.