c++ error C2662 cannot convert ‘this’ pointer from ‘const Type’ to ‘Type &’

CombatEventType getType();

needs to be

CombatEventType getType() const;

Your compiler is complaining because the function is being given a const object that you’re trying to call a non-const function on. When a function gets a const object, all calls to it have to be const throughout the function (otherwise the compiler can’t be sure that it hasn’t been modified).

Leave a Comment