My code is to get data for football players from user. I have written the first part but I am having difficulties running it as compiler raises "use of undeclared identifier" error for "enterplayer()" in main switch but I declared in the header file and included the header. Could you please take a look? Thanks
main.cpp
#include <iostream>
#include <string>
#include <fstream>
#ifndef HW05F_H
#define HW05F_H
#endif
using namespace std;
struct fbplayer{
string name, position;
int scores, catches, yards, ryards, rushyard;
};
// Declaring array for storing football players
struct fbplayer player[10];
// declaring number of players
int numberplayers = 10;
int main(){
int option;
//Iterate till user want to exit
while (1)
{
//print the menu
cout << "Menu:\n1.Read the player's data. \n2.Print the player's data. "
<<"\n3.Update the data. \n4.Search the data. \n5.Exit \n";
//read the option
cout << "\nEnter your option: ";
cin >> option;
switch (option)
{
case 1:
//read the data
enterplayer();
break;
}
}
}
hw05f2.cpp
#ifndef HW05F_H
#define HW05F_H
#include "main.cpp"
#endif
using namespace std;
void enterplayer(fbplayer *player){
for (int i = 0; i<numberplayers; i++) {
cout<< "\nEnter player details here ";
cout<< "\nEnter player name ";
cin >> player[i].name;
cout << "Enter the position.";
cin >> player[i].position;
cout << "Enter scores of the player";
cin >> player[i].scores;
cout << "Enter catches of the player";
cin >> player[i].catches;
cout << "Enter passing yards of the player";
cin >> player[i].yards;
cout << "Enter receiving yards of the player";
cin >> player[i].ryards;
cout << "Enter rushing yards of the player";
cin >> player[i].rushyard;
}
}
hw05f.h
#ifndef hw05f_h
#define hw05f_h
#include "hw05f2.cpp"
void enterplayer(fbplayer *player);
#endif /* hw05f_h */