The compiler doesn't know what members Entity has at that point. You need to move the definition of PoisonEffect::applyEffect() after the definition of Entity.
class PoisonEffect : public _Effect {
int duration = 5;
int mod = 1;
public:
// implemented after Entity becomes a complete type
void applyEffect(Entity& e) ; /*{
e.onPoison(duration, mod);
}*/
};
class _Buff {
// ...
class Entity {
// ...
};
// at this point, Entity is complete type
void PoisonEffect::applyEffect(Entity& e) {
e.onPoison(duration, mod);
}
Also, do not use a name like _Buff; this is wrong on two counts:
In addition, some identifiers are reserved for use by C++ implementations and shall not be used otherwise; no diagnostic is required.
Each identifier that contains a double underscore __ or begins with an underscore followed by an uppercase letter
is reserved to the implementation for any use.
Each identifier that begins with an underscore is reserved to the implementation for use as a name in the global namespace. http://eel.is/c++draft/lex.name
For a vector of non-polymorphic types, strongly favour creating a vector of values:
1 2
// vector<Buff*> buffs; // avoid
std::vector<Buff> buffs ; // this is a good idea
Thanks guys. Just figured out the problem a little bit before the responses. Split up all the files and created headers and everything is working now :)
Will change the Buff class name and vector, thanks for the tips