Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

?
Lv 7

Undefined reference, C++?

When attempting to compile my program, I get an error of "undefined reference to search (char, int, int, int)'. Below is a portion of the program I am writing for my project, so any input on what I may have done wrong would be greatly appreciated. This seems to be my only issue right now with it, and it's anything like my last question it's an obvious mistake I'm missing.

#include <iostream> // cin/cout

#include <fstream> // stream

#include <iomanip> // setw

using namespace std;

void search (char, int, int, int);

int main ()

{

int i = 0;

int SIZE = 0;

char numbers[50];

int tally[50];

int source, num;

char file_name[16];

do

{

cout << "Enter 1 for manual input from keyboard, 2 for reading from a file: ";

cin >> source;

} while (!((source == 1) || (source == 2)));

if (source == 1) // keyboard

{

do

{

cout << "Enter a number (99999 to end): ";

cin >> num;

search (numbers[i], tally[i], num, SIZE);

} while (num != 99999);

}

}

void search (char numbers[], int tally[], int target, int SIZE)

{

int index = 0;

bool found = false;

while ((!found) && (index < SIZE))

{

if (target == numbers[index])

found = true;

else

index++;

}

if (found)

{

tally[index]++;

}

else

{

numbers[SIZE] = target;

tally[SIZE] = 1;

SIZE++;

}

return;

}

3 Answers

Relevance
  • Anonymous
    8 years ago
    Favorite Answer

    change: void search (char, int, int, int);

    may be: void search (char*, int*, int, int);

  • 4 years ago

    you have an unused parameter on your function implementation (double variety) that isn't contemplated in the definition. when you consider that i will see which you're new to programming, i will tricky. The undefined reference function only potential that, while your software tries to execute "opposite(GPA, length)", it recollects which you declared a function named "opposite(double, int)", yet while it seems for the relatively implementation, it would not discover it via extra advantageous parameter and somewhat reads it as a diverse function altogether.

  • 8 years ago

    Could it be that you're calling a method which you've defined to have no method body?

    Are you intending to call the method which requires you to pass an array of characters, an array of ints, and int, and an int? That one has a body, but the other (char, int, int, int) doesn't.

    Dunno.

Still have questions? Get your answers by asking now.