Is it possible to change a C++ object’s class after instantiation?

You can at the cost of breaking good practices and maintaining unsafe code. Other answers will provide you with nasty tricks to achieve this.

I dont like answers that just says “you should not do that”, but I would like to suggest there probably is a better way to achieve the result you seek for.

The strategy pattern as suggested in a comment by @manni66 is a good one.

You should also think about data oriented design, since a class hierarchy does not look like a wise choice in your case.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)