I have added a virtual function to AActor, why can't i compile?

It is not necessary to edit that class. And I would advise strongly against doing it.

You can accomplish what you want by making a new base class that inherits from actor
and then making classes that are children of your new base class