Hi!
I was reading the documentation how to register classes with hierarchy, however i ran into problems while doing it.
In my cpp project, i have two classes which cannot be changed:
class IEntity
{
public:
virtual int GetType();
};
class IPlayer : public virtual IEntity
{
public:
virtual void DoThing();
};
Registering:
template <class T>
void RegisterBaseMembers(asIScriptEngine * engine, const char* type)
{
engine->RegisterObjectMethod(type, "int GetType()", asMETHOD(T, GetType), asCALL_THISCALL);
}
template <class T>
void RegisterMembers(asIScriptEngine * engine, const char* type)
{
RegisterBaseMembers<T>(engine, type);
engine->RegisterObjectMethod(type, "void DoThing()", asMETHOD(T, DoThing), asCALL_THISCALL);
}
//later
RegisterBaseMembers<IEntity>(engine, "Entity");
RegisterMembers<IPlayer>(engine, "Player");
Errors:
'type cast': cannot convert from 'int (__cdecl IEntity::* )(void) const' to 'void (__cdecl IPlayer::* )(void)'
'asSMethodPtr<16>::Convert': no matching overloaded function found
Seems like it works only if the inheritance is not public virtual, but the problem is, im not allowed to change the IEntity and IPlayer classes.
Thanks!