Answer the question
In order to leave comments, you need to log in
How to inherit properties and methods of a class from two other classes?
I have two classes : Hero and Talent . The Hero class has properties: name , health , force ; methods: getName , getHealth , getForce . The Talent class has properties: name , duration , type ; methods : getName , getDuration , getType . How to create a class derived from these two classes in order to inherit their properties and methods?
There is a code (simplified) written in c++:
class Hero {
protected :
std::string name;
double health, force, dexterity, intelligence = 1;
public :
std::string getName(void) { return(name); }
double getHealth(void) { return(health); }
double getForce(void) { return(force); }
double getDexterity(void) { return(dexterity); }
double getIntelligence(void) { return(intelligence); }
};
class Talent {
protected :
std::string name;
double duration = 0;
bool type;
public :
std::string getName(void) { return(name); }
double getDuration(void) { return(duration); }
double getType(void) { return(type); }
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question