To do this is very rude and simple.
Safe
Under “safe code,” your teacher probably means managed code . This is code where you don’t need to “take care” of pointers and memory, you have a garbagecollector that takes care of this for yours. You are dealing with reflections. Examples of such languages are java and C #. The code compiles into "fictional" opcodes (intermediate language, IL for C #), and also compiles and runs in real time (JIT, only at compile time). The code generated by IL must be converted to real code based on its own platform, in java this is one of the things jvm does. You can easily parse code in such languages. And they can work on several platforms without recompilation.
Dangerous
By "unsafe code", a teacher means ordinary native C ++ unmanaged code , where all memory and resource management is done by you. This creates opportunities for human errors, memory leaks, resource leaks, and other memory errors that you usually cannot handle in managed languages. It also compiles into pure bytecode (native build operations codes), which means that you must compile your code for each platform that you intend to target. You will find that you will need to do a lot of code for each platform, depending on what you are going to code. It's nice to see that simple things like threads, which are platform dependent, are now part of the C ++ standard.
Then you have C ++ / CLI, which is basically a mix. You can use managed code from a .net structure in C ++, and it can be used as a bridge and used to create wrappers.
Console::WriteLine() controlled by .net code, safe.
cout is standard iso C ++ from <iostream> , unsafe
Here you will find a related post with a wider answer here and here :)
Edit
As indicated by the Deduplicator below this is also of interest to you
Hope this helps.
Greetings
Stígandr
source share