I am currently trying to write an application that will set up a database for Game Players to register with, to start off I have tried to set up a Class to take the player details and return them when requested. The only problem is I get a load of error messages that make no sense to me. Here is the code
Player.h
#pragma once
#include <STRING>
using namespace std;
class Player
{
private:
int score;
string nickname, firstname, surname, email, password;
int played;
float ratio;
public:
Player(string nick, string fname, string sname, string mail, string pass);
~Player(void);
int addscore(int x);
int getscore();
int addplayed(int y);
int getplayed();
int clacratio();
float getratio();
string getnick();
string getfirstname();
string getsurname();
string getemail();
string getpassword();
};
Player.cpp
#include "player.h"
Player::Player(string nick, string fname, string sname, string mail, string pass)
{
nickname = nick;
firstname = fname;
surname = sname;
email = mail;
password = pass;
score = 0;
played = 0;
ratio = 0;
}
Player::~Player(void)
{
}
Player::getnick()
{
return nickname;
}
Player::getfirstname()
{
return firstname;
}
Player::getsurname()
{
return surname;
}
Player::getemail()
{
return email;
}
Player::getpassword()
{
return password;
}
Player::getplayed()
{
return played;
}
Player::addplayed(int y)
{
played+=y;
}
Player::getratio()
{
return ratio;
}
Player::clacratio()
{
ratio = (score/played);
return 0;
}
Player::addscore(int x)
{
score+=x;
return 0;
}
Player::getscore()
{
return score;
}
Errors
e:\Visual Studio Projects\FileIOTest\Player.cpp(25): error C2371: ''Player::getfirstname'' : redefinition; different basic types
e:\Visual Studio Projects\FileIOTest\Player.cpp(35): error C2371: ''Player::getemail'' : redefinition; different basic types
e:\Visual Studio Projects\FileIOTest\Player.cpp(20): error C2371: ''Player::getnick'' : redefinition; different basic types
e:\Visual Studio Projects\FileIOTest\Player.cpp(40): error C2371: ''Player::getpassword'' : redefinition; different basic types
e:\Visual Studio Projects\FileIOTest\Player.cpp(55): error C2371: ''Player::getratio'' : redefinition; different basic types
e:\Visual Studio Projects\FileIOTest\Player.cpp(30): error C2371: ''Player::getsurname'' : redefinition; different basic types
e:\Visual Studio Projects\FileIOTest\Player.cpp(35): error C2556: ''int Player::getemail(void)'' : overloaded function differs only by return type from ''std::string Player::getemail(void)''
e:\Visual Studio Projects\FileIOTest\Player.cpp(25): error C2556: ''int Player::getfirstname(void)'' : overloaded function differs only by return type from ''std::string Player::getfirstname(void)''
e:\Visual Studio Projects\FileIOTest\Player.cpp(20): error C2556: ''int Player::getnick(void)'' : overloaded function differs only by return type from ''std::string Player::getnick(void)''
e:\Visual Studio Projects\FileIOTest\Player.cpp(40): error C2556: ''int Player::getpassword(void)'' : overloaded function differs only by return type from ''std::string Player::getpassword(void)''
e:\Visual Studio Projects\FileIOTest\Player.cpp(55): error C2556: ''int Player::getratio(void)'' : overloaded function differs only by return type from ''float Player::getratio(void)''
e:\Visual Studio Projects\FileIOTest\Player.cpp(30): error C2556: ''int Player::getsurname(void)'' : overloaded function differs only by return type from ''std::string Player::getsurname(void)''
e:\Visual Studio Projects\FileIOTest\Player.cpp(61): warning C4244: ''='' : conversion from ''int'' to ''float'', possible loss of data
Please help!