Linker Error??

The code I am trying to write is supposed to take a total amount of cents and convert them to numbers of quarters, dimes, and pennies, while trying to make sure you have the maximum amount of larger coins. (Basically, 75 cents is 3 quarters, not 7 dimes and 5 pennies.) The problem is a Linker Error saying there is an "[Linker error] undefined reference to 'outp(int&, int&, int&, int&)'," and "ld returned 1 exit status." Any help would be appreciated, even if it isn't directly about the Linker Error.

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
  #include <iostream>
using namespace std;

void inp(int& total);//sets 'q_25,' 'q_10,' 'p_1,' equal to user's input
void calc(int& total, int& q_25, int& d_10, int& p_1);//converts to individual coins & calculates output
void outp(int& total, int& q_25, int& d_10, int& p_1);//outputs results in individual coins

int main()
{
    
    char cont = 'y';
    int total, q_25, d_10, p_1;
    
    do//do-while loop allows program to be run multiple times
    {inp(total);
    calc(total, q_25, d_10, p_1);
    outp(total, q_25, d_10, p_1);
    cin >> cont;}
    while(cont == 'y' || cont == 'Y');
    
    return 0;}
    
void inp(int& total)//***INPUT***
{
    cout << "Enter the total amount of cents in change that you are trying to get.\n";//prompt
    
    //Take 'total'
    cin >> total;
    while(total < 0)//edge case if total is less than 0
    {cout << "Please enter a positive whole number. Try Again.\n";
    cin >> total;}
    cout << " cents?\n"
         << total << " cents can be exchanged for...\n";}

void calc(int& total, int& q_25, int& d_10, int& p_1)//***CALCULATIONS***
{
    //converts total cents to individual coins, and subtracts value of that coin from total amount
    q_25 = 0;
    d_10 = 0;
    p_1 = 0;
    
    while(total >= 25)//loops until no more quarters can be taken from total
    {total = total - 25;//subtracts value of coin from total
    q_25 = q_25 + 1;}//for every coin value removed, add one to the number of coins
    
    while(total >= 10)//loops...dimes
    {total = total - 10;
    d_10 = d_10 + 1;}
    
    while(total >= 1)//loops...pennies(or any coins)
    {total = total - 1;
    p_1 = p_1 + 1;}}
    
void outp(int total, int q_25, int d_10, int p_1)//***OUTPUT***
{
    cout << "Your total amount of change is " << q_25;
    if (q_25 == 1)
    cout << " quarter, ";
    else
    cout << " quarters, ";
    
    cout << d_10;
    if (d_10 == 1)
    cout << " dime, ";
    else
    cout << " dimes, ";
    
    cout << "and " << p_1;
    cout << p_1;
    if (p_1 == 1)
    cout << " penny.\n\n";
    else
    cout << " pennies.\n\n";
    
    cout << "Do you want to continue? < 'y' or 'n' >: ";}
Hi,
you forgot to put '&' after "int" at line 54.
I hope it helps.
Your prototype for the outp() function doesn't match the definition :

prototype : void outp(int& total, int& q_25, int& d_10, int& p_1);

definition : void outp(int total, int q_25, int d_10, int p_1) { ... }

you specify that all of the parameters in the prototype is passed by reference, but the definition says it is passed by value
Thanks! My program can launch now, and it works fine.
Topic archived. No new replies allowed.