Referencia indefinida a 'Class :: Class'
Después de solucionar el problema anterior (vea mi otra pregunta que he hecho). Había declarado más clases.
Uno de estos se llama CombatAdmin que hace varias cosas: (archivo de encabezado)
#ifndef COMBATADMIN_H
#define COMBATADMIN_H
#include <string> // Need this line or it complains
#include <Player.h>
#include <Sound.h>
#include <Enemy.h>
#include <Narrator.h>
using namespace std;
class Enemy;
class Player;
class CombatAdmin // Code yet to be commented here, will come soon.
{
public:
CombatAdmin();
void healthSet(double newHealth, string playerName);
void comAdSay(string sayWhat);
void playerFindsChest(Player *player,Weapon *weapon,Armour *armour);
void youStoleOurStuffEncounter(Player *player);
void comAdWarning(string enemyName);
void comAdAtkNote(string attack, double damage,string target,string aggresor);
void entDefeated(string entName);
void comAdStateEntHp(string ent, double hp);
void comAdStateScanResults(string enemyName, double enemyHealth);
string doubleToString(double number);
string intToString(int number);
bool isRandEncounter();
void randomEncounter(Player *player,Sound *sound,Narrator *narrator);
bool combatRound(Player *player, Enemy *enemy, Sound *sound, bool ran);
void playerFindsItem(string playerName,string itemName,double itemWeight,double playerWeight);
void playerFindsGold(string playerName,double coinCnt,double playerCoinCnt);
};
#endif // COMBATADMIN_H
uego se instancia en el archivo main.cpp de esta manera: (Fragmento del archivo main.cpp)
#include <iostream> // Required for input and output
#include <Item.h> // Item header file.
#include <Weapon.h> // Header files that I have made for my classes are needed for this program
#include <sstream> // Needed for proper type conversion functions
#include <windows.h> // for PlaySound() and other functions like sleep.
#include <time.h> // Needed to seed the rand() function.
#include <mmsystem.h> // Not sure about this one, possibly defunct in this program.
#include <stdio.h> // Needed for a similar kind of output as iostream for various functions error msgs.
#include <irrKlang.h> // The header file of the sound lib I am using in this program.
#include <Narrator.h> // The narrators's header file.
#include <Pibot.h> // Other header files of classes.
#include <Armour.h>
#include <Player.h>
#include <Weapon.h>
#include <CombatAdmin.h>
using namespace irrklang;
using namespace std;
// Forward referenced functions
void seedRandom(); // Seeds the random number so it will be random as apposed to pseudo random.
string getPlayerName(string temp); // Gets the player's new name.
int main(int argc, char* argv[])
{
// Variables and object pointers declared here.
CombatAdmin *comAd = new CombatAdmin(); // Handles combat.
Narrator *narrator = new Narrato,r(); // The Narrator that says stuff
Pibot *piebot = new Pibot(); // PIbot, the player's trusty companion
string temp; // Temp string for input and output
Sin embargo, cuando intento compilar el proyecto, aparece el siguiente error:
C:\Documents and Settings\James Moran.HOME-B288D626D8\My Documents\C++ projects\Test Project\main.cpp|59|undefined reference to `CombatAdmin::CombatAdmin()'|
Estoy usando Code :: Blocks IDE (ver 10.05), con el compilador GNU GCC. El proyecto es de tipo "Aplicación de consola". Estoy usando Windows XP 32 bit SP3.
He intentado cambiar a los directorios de búsqueda para incluir dónde están los archivos de objetos, pero no tuve éxito allí.
omo se puede ver en el código, el narrador y "PIbot" se instalan perfectamente. (luego usado, no se muestra)
Mi pregunta es, por lo tanto, ¿qué debo hacer para evitar que ocurran estos errores? Como cuando encontré errores similares de "Referencia indefinida a x" antes de usar bibliotecas. Acababa de olvidar vincularlos en Code :: Blocks y tan pronto como lo hiciera, funcionarían.
Como esta clase es de mi propia creación, no estoy muy seguro de esto.
Diga si necesita más información sobre el código, etc.