Originally Posted by
matsp
What I meant is that we probably need to see the SOURCE where those things happen [or even better, a stripped down version of your code that compiles with the relevant bits that cause you problems present in the code as a single source file].
--
Mats
Ah okay, i'll post up my whole project, because I haven't got that much code at the moment anyways:
This is game.cpp (the driver, and where everything will happen
Code:
#include <iostream>
#include "Player.h"
using namespace std;
int main()
{
char first[10];
char last[10];
cout<< "Please enter first name: " << endl;
cin>> first;
cout<< "\nPlease enter last name: " << endl;
cin>> last;
Player player1(first, last);
//This is just a test of the Player functions, notice they return only the first letter of array.
cout<< "Player 1 first name: " << player1.getFirstName() << endl;
cout<< "Player 1 last name: " << player1.getLastName() << endl;
system("PAUSE");
}
This is Player.h, defines the Player class and its' attributes:
Code:
#include <string.h>
class Player
{
public:
Player(char *firstName, char *lastName);
char* getFirstName();
char getLastName();
int getPosition();
void printFirstName();
void printLastName();
int getPlayerNumber();
enum skill{BATTER, PITCHER, CATCHER, FIELDER};
private:
char playerFirstName[10];
char playerLastName[10];
bool teamId;
enum position{OFF_FIELD, PITCHER_PLATE, BATTING_PLATE,
FIRST_BASE, SECOND_BASE, THIRD_BASE,
INNER_RIGHT, INNER_CENTER, INNER_LEFT,
OUTER_RIGHT_FOUL, OUTER_RIGHT_WALL,
OUTER_LEFT_FOUL, OUTER_LEFT_WALL,
HOME_RUN};
skill currentSkill;
int playerNumber;
};
Finally, this is Player.cpp, defines all the functions in Player.h :
Code:
#include "Player.h"
using namespace std;
Player::Player(char *firstName, char *lastName)
{
strcpy(playerFirstName, firstName);
strcpy(playerLastName, lastName);
}
char* Player::getFirstName()
{
return playerFirstName;
}
char Player::getLastName()
{
return *playerLastName;
}
int Player::getPlayerNumber()
{
return playerNumber;
}
Phew! sorry about such a monstrous post!
Any idea on what i'm doing wrong?
Regards,
-Kirill