Hello, i have a book that is teaching me the basics of c++
i understand most of it and its really fun, but i need some help creating my own applacation.
i want to create a class caled bandit and have a sub class scout
so that under bandits i can have scout artillary ect.
i also want these broken into seprate .h files like bandits.h and mines.h ect
my problem is calling the class in the .h file from my main.cpp file i get an error
C:\Cpp_Docs\Test\main.cpp `Bandit' undeclared (first use this function)
here is the code i have right now. i am just trying to be able to use the class in the main.cpp and still have the class in the .h file
Thanks BM
main.cpp
#include "\\bandit.h"
#include <iostream>
using namespace std;
//Global
int main()
{
Bandit *pScout = new Scout;
}
bandit.h
#include <iostream>
class Bandit
{
public:
Bandit(); // constructor
~Bandit(); // destructior
//functions
bool return_alive();
int return_health();
int return_armour();
//generic
int health;
int armour;
private:
};
Bandit()
{
std::cout<<"Bandit Constructed\n";
~Bandit()
{
std::cout<<"Bandit Deconstructed\n";
}
bool return_alive()
{
if (health > 0)
{
return true;
}
else
{
return false;
}
}
int return_health()
{
return health;
}
int retunr_armour()
{
return armour;
}
class scout : public Bandit
{
public:
scout(); // constructer
~scout(); // destructer
void set_speed(int Speed);
void set_armour(int Armour);
void set_health(int Health);
void set_damage(int Damage);
void set_hitChance(float HitChance);
private:
int speed;
int armour;
int health;
int damage;
float hitChance;
};
scout()
{
std::cout<<"Scout created\n";
}
~scout();
{
std::cout<<"Scout Destryed\n";
}
void set_speed(int Speed)
{
speed = Speed;
}
void set_armour(int Armour)
{
armour = Armour;
}
void set_health(int Health)
{
health = Health;
}
void set_damage(int Damage)
{
damage = Damage;
}
void set_hitChance(float HitChance)
{
hitChance = HitChance;
}