Made compilable by g++ and fixed undefined virtual functions