complie error

my code stops running at
populate_div_sales(div_sales, div_regions, 4); and gives me errors saying

en242@cs04:~> c++ top_div_array.cpp -o top_div_array
/tmp/ccIPcn3r.o(.text+0xc2): In function `main':
: undefined reference to `populate_div_sales(float*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, int)'
collect2: ld returned 1 exit status

in a shell the whole code works as im doing piece by piece cause my pico complier is giving lot of errors. , so now im doing little by little so it runs and i know where its giving errors.

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


void populate_div_sales(float[], string[], int);
int findHighest (float[], int);
void print_result(float[], string[], int);

int main ()
{
int top_div_index = 0;
float div_sales[4];
string div_regions[4];


div_regions[0] = "Northeast";
div_regions[1] = "Southeast";
div_regions[2] = "Northwest";
div_regions[3] = "Southwest";

populate_div_sales(div_sales, div_regions, 4);
return 0;
}



You did not implement populate_div_sales(...). There is only the prototype on line 7 but that isn't the implementation.
Hello poonamp6792,

Adding to what coder777 said what that confusing compiler message says if that you forward declared the function name at line 7 in the prototype, but have yet to actually write the function.

The error message is kind of cryptic and hard to understand right now. Once you have made this mistake a few time and learn how to read your error messages it gets easier. Some times you may find that this type of error message happens when you misspell something where. Either the prototype, function call or function definition.

Sometimes you will find an error message that refers to a line number, but the actual error in in the line above or it may be two or three lines above. Just something to keep in mind.

Hope that helps,

Andy
Topic archived. No new replies allowed.