We were taught about static_cast in the C++ course, but I completely forgot what it does

@vaporeon_ to oversimplify a bit it's like a c-style cast that has a lot more restrictions,and is checked by the compiler, to protect the programmer from making silly mistakes

@wallhackio What kind of silly mistake? In my mental model, a cast is a way to tell the compiler "I know what I'm doing, don't complain and just consider this type as this other type", and now you're telling me there's a version of that with extra checks?

Follow

@vaporeon_ you can use a C-style cast to convert a pointer to a char to a pointer to a 16-bit integer, which will almost certainly cause a runtime error

static cast won't let you do something like that

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.