Move virtual methods out of line.

This is generally a good thing and in this case should also fix the
BUILD_SHARED_LIBS=ON build (see pr19774).