-3

I am having trouble with understanding this error that I am receiving.The object of this assignment is to create a program that prints out 13 school teams, their records, and then to print out the teams who are over .500 in wins. The error occurs inside of my main function when trying to deal with the winning_teams function.

exit status 1
/tmp/ccSw87Of.o: In function `main':
main.cpp:(.text+0x8ea): undefined reference to `winning_teams(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, double, double, double)'
collect2: error: ld returned 1 exit status

Here is my code! please help if you can

#include <iostream>
#include<string>
using namespace std;

struct Team 
{
  string name;
  int wins;
  int losses;
};



double win_percentage (string , double , double );
void wins_losses (string , double , double , double );
void winning_teams (string , double , double , double );

int main(){
  int const NUM = 13;

  Team school[NUM]= {
    {"Bethune-Cookman", 11, 3}, {"Coppin State", 5, 9}, {"Delaware State", 1, 13},{"Florida A&M", 6, 8},{"Hampton", 11, 4},{"Howard", 6, 8},{"Maryland Eastern Shore", 2, 12},{"Morgan State", 6, 8},{"North Carolina A&T", 10, 4}, {"North Carolina Central", 8, 6},{"Norfolk State", 10, 4},{"Savannah State", 10, 4},{"South Carolina State", 6, 8}};

  cout<< "MEAC MENS BASKETBALL TEAMS CONFERENCE STANDINGS"<< endl;

  for (int i = 0; i<NUM; i++){

     cout<< school[i].name<<" "<<school[i].wins<<"-"<<school[i].losses<< endl;

    cout<<"TEAMS WINNING PERCENTAGE"<<endl;
    win_percentage(school[i].name,school[i].wins,school[i].losses);

    cout<<"TEAMS WITH WINNING RECORDS"<<endl;

    wins_losses(school[i].name,school[i].wins,school[i].losses, win_percentage(school[i].name,school[i].wins,school[i].losses));

    winning_teams(school[i].name,school[i].wins,school[i].losses,win_percentage(school[i].name,school[i].wins,school[i].losses));
  }
  return 0;
}

double win_percentage(string a, double b, double c){
  double x;
  x = (b/(b+c));
  return x;
  cout<< a<<" "<<x<<endl;

}
void wins_losses( string e, double f, double g, double h){

   cout<< e<< "Record is"<<f<<"-"<<g<< h<<endl;
}
void winning_teams(string w, int f, int y, double z){
  if ( z >.500){
    cout<< w<<" "<<f<< "-"<<y<< " "<< z<< endl;


  }
}
willydave
  • 1
  • 1
  • where is **body** of your `winning_teams()` function? Because it looks that is nowhere. – Marcin Orlowski Mar 14 '18 at 02:27
  • 2
    Ctrl + F your own post, look for "winning_teams", and check if the function parameter lists match across your program. –  Mar 14 '18 at 02:28
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Miles Budnek Mar 14 '18 at 02:28

1 Answers1

2

In your winning_teams declaration, function parameters list are string,double,double,double! But in your definition, it is different, i.e., string,int,int,double!

As function definition doesn't match, it throws error!

possible solution:

void winning_teams(string w, double f, double y, double z){
if ( z >.500){
cout<< w<<" "<<f<< "-"<<y<< " "<< z<< endl;} 
Aswin
  • 137
  • 2
  • 9