hey what's up guys my name is Jonah welcome back to my C++ series so today we're gonna be talking all about type punning in C++ and type planning is really just a fancy term for just us kind of getting around the type system in C++ so C++ is a strongly typed language which means that we have a type system we don't declare everything as auto I mean we kind of can because of that kit word but in other languages like JavaScript there are no kind of sense of variable types really and we just have we don't need to declare a variable type when we create a variable and when we accept it in its parameters into functions or anything like that we don't have a type system really but it's a plus plus of course we do have a type system we have to declare things as integers or doubles or bullying's or structs or classes all that stuff when we actually create variables however this type system is not really enforced as strongly as it is in other languages such as Java where it's really hard to get around types and even c-sharp but you can do it but it's a bit more work in C++ whilst types are kind of enforced by the compiler you can directly access memory which means that you can kind of say that hang on a minute I know that at the moment in my code I've been using this type as say an integer but actually I'm gonna just grab that memory that same memory and just treat it as a double now or as a class or something like that and you can just get around the type system really easily now whether what you should is going to again depend on your actual circumstance in some cases you absolutely should not circumvent the type system because the type system is there for a reason and you probably don't want to be playing around with a NUMBER_TOKEN-month unless you have a good reason but in other cases it's totally okay to do that for example let's just say we had a class and we wanted to write it out as a stream of bytes well instead of kind of going through everything as assuming it's like a structure of primitive types it doesn't have pointers to other places in memory we can just kind of reinterpret that entire struct or class or whatever we have as just a byte array and just write that out or stream it somewhere right we don't have to even care about what types are in it so we know the size we can just get the get to get the data access it and then just put it somewhere so in a lot of cases it is really useful and it means that it's kind of that raw I guess low level access that is why I really like C++ and why suppose was is so effective in applications where performance is required anyway not talking let's just dive in take a look at a few examples this is something that I use quite often so you'll probably see it in other videos and especially like in the OpenGL serious and the game end deserts and all that so you'll see plenty of this this is just gonna be a basic overview but let's just dive in and see what we can do okay so in that first example I kind of declared an integer well I just said that I had an integer and then I just wanted to treat it as a double well of course in this case that's probably gonna result in and pretty weird-looking double and not something that
NO_SEGMENT_TOKEN