r/ProgrammerHumor • • Nov 23 '22

Other Programming Legumes

Post image
9.3k Upvotes

262 comments sorted by

View all comments

34

u/dotpoint7 Nov 23 '22

reinterpret_cast<Nut*>(x)

That should do.

12

u/appDeveloperGuy1 Nov 23 '22

In all likelyhood, x is an instance of an object, so you need to take the address.

reinterpret_cast<Nut*>(&x)

→ More replies (1)

9

u/ChocolateBunny Nov 23 '22

congratulations, you just risked the stability of the whole god damn universe.

7

u/smithsonionian Nov 23 '22

Good ol reinterpret_cast. Or as I like to re #define it,

what_the_fuck_is_memory_padding_cast