hey guys, how are you all.
i am having a little problems in linking my files. i am using gcc compiler.

the command line that i use is g++ -c player.cpp to create the first object file

player.h

class Player_Type
{
private:
int id;
string fname;
string lname;
string team;
int wickets;
int runs;
int matches;

public:
void setfname(string);
void setlname(string);
void setteam(string);
void setwickets(int);
void setruns(int);
void setmatches(int);
string getfname();
string getlname();
string getteam();
int getwickets();
int getruns();
int getmatches();
};

player.cpp
this has the definitions of the class in my header file

#include <cstring>
#include "player.h"

using namespace std;


void Player_Type::setfname(string name1)
{

fname=name1;

}


void Player_Type::setlname(string name2)
{

lname=name2;


}


void Player_Type::setteam(string team1)
{

team=team1;

}
void Player_Type::setwickets(int wick)
{
wickets=wick;
}

void Player_Type::setruns(int run)
{
runs=run;
}

void Player_Type::setmatches(int match)
{
matches=match;
}



string Player_Type::getfname()
{

return fname;
}

string Player_Type::getlname()
{

return lname;
}


string Player_Type::getteam()
{

return team;
}

int Player_Type::getwickets()
{
return wickets;
}

int Player_Type::getruns();
{
return runs;
}

int Player_Type::getmatches()
{
return matches;
}

game1.cpp
this is the code which has the main function

#include <iostream>
#include <cstring>
#include <fstream>
#include "player.h"
using namespace std;


int main()
{



ifstream infile;
infile.open("player.txt");
if(!infile)
{
 cout<<"Sorry, but the file does not exist. Please make sure that the file is available."<<endl;

}//end of if(!infile)

string fname,lname,team;
int wick,run, match,no,i;

infile>>no;

Player_Type *player=new Player_Type[no];



if(infile)
{

for(i=0;i<no;i++)
{
infile>>fname;
player[i].setfname(fname);
infile>>lname;
player[i].setlname(lname);
infile>>team;
player[i].setteam(team);
infile>>wick;
player[i].setwickets(wick);
infile>>run;
player[i].setruns(run);
infile>>match;
player[i].setmatches(match);
}//end of for loop


for(i=0;i<no;i++)
{
cout<<player[i].getfname()<<" ";
cout<<player[i].getlname()<<" ";
cout<<player[i].getteam()<<" ";
cout<<player[i].getwickets()<<" ";
cout<<player[i].getruns()<<" ";
cout<<player[i].getmatches()<<" ";
cout<<endl;
}//end of for loop 

}//end of if(infile)

infile.close();//this closes the input file

delete []player;
return 0;

}

the following are the errors i get in gcc

F:\cricket game>g++ -c player.cpp
In file included from player.cpp:2:
player.h:7: 'string' is used as a type, but is not defined as a type.
player.h:8: 'string' is used as a type, but is not defined as a type.
player.h:9: 'string' is used as a type, but is not defined as a type.
player.h:15: `string' was not declared in this scope
player.h:15: invalid data member initialization
player.h:15: (use `=' to initialize static data members)
player.h:15: variable or field `setfname' declared void
player.h:16: `string' was not declared in this scope
player.h:16: invalid data member initialization
player.h:16: variable or field `setlname' declared void
player.h:17: `string' was not declared in this scope
player.h:17: invalid data member initialization
player.h:17: variable or field `setteam' declared void
player.h:21: parse error before `)' token
player.h:22: parse error before `)' token
player.h:23: parse error before `)' token
player.cpp:7: `string' was not declared in this scope
player.cpp:7: parse error before `)' token
player.cpp:8: no `void Player_Type::setfname(...)' member function declared in
class `Player_Type'
player.cpp: In member function `void Player_Type::setfname(...)':
player.cpp:10: `fname' undeclared (first use this function)
player.cpp:10: (Each undeclared identifier is reported only once for each
function it appears in.)
player.cpp:10: `name1' undeclared (first use this function)
player.cpp: At global scope:
player.cpp:15: `string' was not declared in this scope
player.cpp:15: parse error before `)' token
player.cpp:16: no `void Player_Type::setlname(...)' member function declared in

class `Player_Type'
player.cpp: In member function `void Player_Type::setlname(...)':
player.cpp:18: `lname' undeclared (first use this function)
player.cpp:18: `name2' undeclared (first use this function)
player.cpp: At global scope:
player.cpp:24: `string' was not declared in this scope
player.cpp:24: parse error before `)' token
player.cpp:25: no `void Player_Type::setteam(...)' member function declared in
class `Player_Type'
player.cpp: In member function `void Player_Type::setteam(...)':
player.cpp:27: `team' undeclared (first use this function)
player.cpp:27: `team1' undeclared (first use this function)
player.cpp: At global scope:
player.cpp:47: syntax error before `::' token
player.cpp:53: syntax error before `::' token
player.cpp:60: syntax error before `::' token
player.cpp:71: declaration of `int Player_Type::getruns()' outside of class is
not definition
player.cpp:72: parse error before `{' token
player.cpp:79:2: warning: no newline at end of file

i would really appreciate your help

thanx in advance

C++ strings are in #include <string>
Use this if you want a string type.

C strings (strcpy et al) are in #include <cstring>

This question has already been answered. Start a new discussion instead.