Defined BaseEntity functions in cpp

It's easier to define in the class definition, but better to define in
the cpp.