
-----------------------------------
DrummaBoyFB
Sun Apr 18, 2010 7:33 pm

Using data from other classes
-----------------------------------
Hi, I'm trying to make a text based battle game and I'm having trouble with one part.
I want to be able to interact with other classes but I don't know how to and I'm not to keen on how to use
Inheritance. Whenever I try to use inheritance I understand that it copies the contents of the class file into the 
the other class.
But I declare the values for my variables my classes in a .cpp file. so the other classes don't recognize the other classes files.
I don't know if there's another way to do it or if somebody could explain how to use inheritance properly.

I'm going to post my code to show you my problem.
(where it's bold, underlined, or both is where the problems are)


// player.h
#pragma once
#include "stdafx.h"
#include 
#include "enemy.h"
using namespace std; 

class player  
{
public:

player (int atkvalue, double totalexp, int healthvalue);
void attack();
void defend();
int heal();
void level();
void death();
void hurt ();
void expgain ();


double expvalue;
int totalhealth;
double totalExp;
int totalatk;
int damage;
int health;
double exppoints;
int lives;
int defense;
int healthgain;
int healthloss;


};




//player.cpp
#pragma once 

#include "stdafx.h"
#include 
#include "player.h"
#include "enemy.h"
using namespace std;

player::player (int atkvalue, double totalexp, int healthvalue)
{
damage = totalatk / 4;
health = healthvalue;
exppoints = 0;
lives = 3;
defense = edamage / 4;
healthgain = 10;
healthloss = 0;
totalhealth = healthvalue;
expvalue = etotalatk / 3;
totalExp = totalexp;
totalatk = atkvalue;

}


void player::attack ()
{
cout 