Thanks for the help so far.
Ok, I originally had this:
Main.cpp:
Code:
/* main.cpp */
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "battle.h"
#include "enemy.h"
using namespace std;
int battle(Character, Character);
Character Enemy1("Goblin",50,2,2); // enemy character
Character Person("Normal Person",100,10,10); // hero
int main()
{
battle(Person,Enemy1);
return 0;
}
Battle.h
Code:
/* battle.h */
#ifndef BATTLE_H_INCLUDED
#define BATTLE_H_INCLUDED
class Character
{
public:
Character(char*,int,int,int); //constructor
int get_hp(Character);
void hit(Character&);
void enemyhit(Character&);
void display(Character,Character);
private:
char *name;
int hp;
int attack;
int defence;
};
Now I wanted to have an enemy.cpp file that did this:
Code:
/* enemy.cpp */
#include "enemy.h"
#include "battle.h"
Character Enemy2("Goblin2",60,4,4); // A new enemy
And what I wanted to happen was for the Enemy2 character in enemy.cpp to get passed to main.cpp
so I could easily add enemies and stuff, and they could then be used in the main battle loop.
However I did the pointer thing with the Character class, but still can't get it passed to main.cpp.
Code:
/* enemy.cpp */
#include "enemy.h"
#include "battle.h"
Character* Enemy2 = new Character("Goblin2",50,2,2); // A new enemy
Is that right? Should I be doing something different to be able to pass the Enemy2 character to my battle loop?