0
    #include <iostream>
    #include <iomanip>
    #include <string>

    using namespace std;

    const int numplayers = 10;
    const int numscores = 3;

    void playerNames(string[],int);
    void batsHits(int[][numscores],double[][numscores],int, int,string[]);
    void battingAverage(int[][numscores],double[][numscores],int,int);
    void displayStats(int[][numscores],double[][numscores],double[], string[], int, int);

    int main()
    {
        // Declaration and Initialization Statements
        int bats[numplayers][numscores];            //Players number of at bats
        double playerhits[numplayers][numscores];    //Players number of hits
        string playernames[numplayers];                //Players names
        double avgplayerscores[numplayers];            //Players average scores

        // Function Calls
        playerNames(playernames,numplayers);
        batsHits(bats, playerhits, numplayers,numscores,playernames);
        battingAverage(bats,playerhits,numplayers,numscores);
        displayStats(bats,playerhits,avgplayerscores,playernames,numplayers,numscores);
    }

    //Collects the baseball players names from user
    void playerNames(string playernames[], int numplayers)
    {
        int i;

        for(i=0;i<numplayers;i++)
        {
            cout << "Please enter Player #" << i+1 << "'s name: ";
            getline(cin,playernames[i]);
        }
    }

    //Gets the number at bats and hits for each player
    void batsHits(int bats [][numscores],double hits [][numscores], int numplayers, int numscore,string playernames[])
    {
        int i;
        int j;

        for(i=0;i<numplayers;i++)
        {
            for(j=0;j<numscores;j++)
            {
                cout << "Enter " << playernames[i] << "'s At Bats: " << endl;
                cin >> bats[i][j];
                cout << "Enter " << playernames[i] << "'s Hits: " << endl;
                cin >> hits[i][j];
            }
        }
    }

    //Calculates the batting average for each player
    void battingAverage(int bats[][numscores],double avgplayerscores[],int numplayers,int numscores)
    {
        int i = 0;
        int j = 0;
        double total = 0;

        for(i;i<numscores;i++)
        {
            for(j=0;j<numplayers;j++)
            {
                total+=bats[j][i];
            }
            avgplayerscores[i]=(total/(j+1)*1.0);
            total=0;
        }
    }

    //Displays the players stats and calculates the total number of hits and bats for the whole team.
    void displayStats(int bats[][numscores],double playerhits[][numscores],double avgplayerscores[],
                      string playernames[], int numplayers, int numscores)
    {
        int i = 0;
        int j = 0;
        double avgbats[10];
        double avghits[10];
        double total = 0;

        for(i;i<numscores;i++)
        {
            for(j=0;j<numplayers;j++)
            {
                total+=bats[j][i];
            }
            avgbats[i]=(total/(j+1)*1.0);
            total=0;
        }

        for(i;i<numscores;i++)
        {
            for(j=0;j<numplayers;j++)
            {
                total+=playerhits[j][i];
            }
            avghits[i]=(total/(j+1)*1.0);
            total=0;
        }

        cout << endl << endl;
        cout << "Player              AB              HITS              AVE"
             << endl;
        cout << playernames[0] << setw(17) << bats[0][0] << setw(17) 
             << playerhits[0][0] << setw(17)  
             << fixed << showpoint << setprecision(1) << avgplayerscores[0] << endl;

        cout << playernames[1] << setw(17) << bats[1][0] << setw(17)
             << playerhits[1][0] << setw(17) 
             << fixed << showpoint << setprecision(1) << avgplayerscores[1] << endl;

        cout << playernames[2] << setw(17) << bats[2][0] << setw(17)
             << playerhits[2][0] << setw(17) 
             << fixed << showpoint << setprecision(1) << avgplayerscores[2] << endl;

        cout << playernames[3] << setw(17) << bats[3][0] << setw(17)
             << playerhits[3][0] << setw(17) 
             << fixed << showpoint << setprecision(1) << avgplayerscores[3] << endl;

        cout << playernames[4] << setw(17) << bats[4][0] << setw(17)
             << playerhits[4][0] << setw(17) 
             << fixed << showpoint << setprecision(1) << avgplayerscores[4] << endl << endl;

        cout << playernames[5] << setw(17) << bats[5][0] << setw(17)
             << playerhits[5][0] << setw(17) 
             << fixed << showpoint << setprecision(1) << avgplayerscores[0] << endl;

        cout << playernames[6] << setw(17) << bats[6][0] << setw(17)
             << playerhits[6][0] << setw(17) 
             << fixed << showpoint << setprecision(1) << avgplayerscores[1] << endl;

        cout << playernames[7] << setw(17) << bats[7][0] << setw(17)
             << playerhits[7][0] << setw(17) 
             << fixed << showpoint << setprecision(1) << avgplayerscores[2] << endl;

        cout << playernames[8] << setw(17) << bats[8][0] << setw(17)
             << playerhits[8][0] << setw(17) 
             << fixed << showpoint << setprecision(1) << avgplayerscores[3] << endl;

        cout << playernames[9] << setw(17) << bats[9][0] << setw(17)
             << playerhits[9][0] << setw(17) 
             << fixed << showpoint << setprecision(1) << avgplayerscores[4] << endl << endl;

        cout << "Totals" << setw(14) << fixed << showpoint << setprecision(1) 
             << avgbats << setw(17) << avghits
             << setw(17) << endl << endl;
    }

error LNK2019: unresolved external symbol "void __cdecl battingAverage(int (* const)[3],double (* const)[3],int,int)" (?battingAverage@@YAXQAY02HQAY02NHH@Z) referenced in function _main

It obviously has to deal with function battingAverage calling in main function, I have searched for this error here, tried to change c++ compiler options to 'Console' but it didn't help. Please help guys, I am sure it is a small issue but I am tired trying to fix it.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
user1743703
  • 133
  • 2
  • 10

1 Answers1

4

Your declaration:

void battingAverage(int[][numscores],double[][numscores],int,int);

Your definition:

void battingAverage(int bats[][numscores],double [],int numplayers,int  numscores)

As you can see, there's a discrepancy on the second argument - double[][numscores] vs double[]. So you're actually defining a whole different function.

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625