Hacker News new | past | comments | ask | show | jobs | submit login

In the case of C++, you can do that via templates and static dispatch, now with C++20 is even better as each entity can be modelled as a concept.

something like,

    template<typename T>
    concept Player = requires (T p) {
        p.jump(); 
    };

    class Factory {
        public:

        template<Player p>
        void register_entity(p player);
    };
Just as seed for the overall idea.



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: