There are compiler plugins for gcc and clang that randomize struct layouts (Randstruct). This is primarily used in the Linux Kernel: https://lwn.net/Articles/722293/
The clang PR: https://reviews.llvm.org/D121556
I'm unsure if these plugins have support for C++ structs/classes but it might be possible.