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

Basically, yeah.

If you modify AActor, then you modify everything that inherits from it, including Epic’s classes. Sometimes you want to do that. That said, unless you intend to send a pull request to Epic, you have just forked the engine and take full responsibility for merging your edits with theirs for each and every update that Epic releases. Not fun. This could be like, one or more full-time jobs worth of person-hours, depending on how much you change.

If your change should only affect YOUR code, then you’ll want to create a subclass of AActor with your edits, and then subclass THAT subclass for any class that should inherit from it (as the quoted statement shows).