Undefined reference error while calling function
I was coding a simple text based RPG when I came across this error. Here's
the file it occurred in (combat_scene.cpp):
#include <iostream>
#include "header.h"
using namespace std;
void combat_scene(string enemy, int xp_gain, int hp, int dmg, int money)
{
enemy_health = hp;
cout << "\n";
cout << "\n"<< name <<" finds a " << enemy << "!";
while (enemy_health>0 && health>0)
{
health -= dmg;
attacking_turn();
}
if (health>0)
{
exp += xp_gain;
gold += money;
location();
}
else
{
cout <<"\nSorry, "<< name << " you died from a "<< enemy << ".";
}
}
This caused the following error:
||=== RPG, Debug ===|
obj\Debug\home_action.o||In function `Z11home_actionv':|
C:\Users\William\Documents\Stuff\Programming\C++\Randomness\RPG\home_action.cpp|64|undefined
reference to `travel_locations()'|
C:\Users\William\Documents\Stuff\Programming\C++\Randomness\RPG\home_action.cpp|67|undefined
reference to `location()'|
||=== Build finished: 3 errors, 0 warnings (0 minutes, 0 seconds) ===|
The header referenced is (header.h):
#ifndef HEADER_H_INCLUDED
#define HEADER_H_INCLUDED
#include <iostream>
using namespace std;
extern int intel;
extern int strength;
extern int sneak;
extern int damage;
extern int max_health;
extern int max_magic;
extern int enemy_health;
extern int health;
extern int magic;
extern string chosen_class;
extern int die_roll;
extern int goal;
extern int gold;
extern int exp;
extern string name;
extern string current_town;
void level_up();
void calculate_max();
void reset_healths();
void spell();
void attacking_turn();
void home_action();
void calculate_roll(int stat, int difficulty);
void combat_scene(string enemy, int xp_gain, int hp, int dmg, int money);
void location();
int main();
void travel_locations();
No comments:
Post a Comment