Hey everyone, I can't figure out this symbol referencing error after looking at it for the longest time, and I figured some fresh eyes might be able to point something out I am overlooking.
Undefined first referenced
symbol in file
Player::Player() /var/tmp/ccqbgWea.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
I've looked at all my files and Player() is declared in the Player class. And in my player.cpp file (contains implementations of public member functions of Player) I have included "player.h" (stores my declaration of the class)
I know my battleground.h and .cpp are not complete but it should still compile fine. I know once I add a constructor in for Battleground it will also give me another symbol referencing error like Battleground::Battleground()
I compile using: g++ pvpranks.cpp
Here is the code if it will help:
battleground.h
#include "player.h"
class Battleground
{
private:
Player bgPlayers[40];
public:
};
battleground.cpp
#include "battleground.h"
using namespace std;
player.h
class Player
{
private:
char pname[13];
char pserver[50];
char prace[10];
char pclass[8];
int pkillingblows;
int phonorkills;
int pdeaths;
int phonorgained;
int pfaction;
int prank;
int pdamage;
int phealing;
int pflagcaps;
int pbasesassaulted;
int pflagreturns;
int pbasesdefended;
public:
Player();
void set_pname(char pn[]);
void set_pserver(char ps[]);
void set_prace(char prac[]);
void set_pclass(char pc[]);
void set_pkillingblows(int pkb);
void set_phonorkills(int phk);
void set_pdeaths(int pde);
void set_phonorgained(int phg);
void set_pfaction(int pfa);
void set_prank(int pran);
void set_pdamage(int pda);
void set_phealing(int ph);
void set_pflagcaps(int pflagc);
void set_pbasesassaulted(int pbasesa);
void set_pflagreturns(int pflagr);
void set_pbasesdefended(int pbasesd);
};
player.cpp
#include "player.h"
using namespace std;
Player::Player()
{
pname = "\0";
pserver = "\0";
prace = "\0";
pclass = "\0";
pkillingblows = 0;
phonorkills = 0;
pdeaths = 0;
phonorgained = 0;
pfaction = 0;
prank = 0;
pdamage = 0;
phealing = 0;
pflagcaps = 0;
pbasesassaulted = 0;
pflagreturns = 0;
pbasesdefended = 0;
}
void Player::set_pname(char pn[])
{
}
void Player::set_pserver(char ps[])
{
}
void Player::set_prace(char prac[])
{
}
void Player::set_pclass(char pc[])
{
}
void Player::set_pkillingblows(int pkb)
{
}
void Player::set_phonorkills(int phk)
{
}
void Player::set_pdeaths(int pde)
{
}
void Player::set_phonorgained(int phg)
{
}
void Player::set_pfaction(int pfa)
{
}
void Player::set_prank(int pran)
{
}
void Player::set_pdamage(int pda)
{
}
void Player::set_phealing(int ph)
{
}
void Player::set_pflagcaps(int pflagc)
{
}
void Player::set_pbasesassaulted(int pbasesa)
{
}
void Player::set_pflagreturns(int pflagr)
{
}
void Player::set_pbasesdefended(int pbasesd)
{
}
pvpranks.cpp
#include "battleground.h"
using namespace std;
int main()
{
Battleground session[50];
return 0;
}