C ++: comprueba si el puntero está apuntando a una memoria válida (no se pueden usar las comprobaciones NULL aquí)
Estoy creando lenguaje de scripting. Cuando asigno una cosa, asigna la cosa y devuelve la dirección y luego hago lo que sea y luego la elimino. No puedo controlar las variables en él como crear struct en mi lang (Struct with pointer y bool para verificar si el puntero está apuntando a datos válidos) y etc., ya que hará que mi lang sea más lento y más grande en la RAM.
Por ejemplo: (Mi lenguaje de scripting es fácil de entender. Dudo que no entiendas esto, pero de todos modos pondré algunos comentarios)
MyStruct = { //Function. For create object with it use 'new' before it.
TestAliveVar=0
}
Func = { //I'll explain what exactly this function does every place it runs.
if (!exists(arg0)) //C++: ???
exit;
arg0.TestAliveVar=1
println "Still alive!";
}
var MyVar=new MyStruct(); //Returns address of the new object in the heap
//and runs on it the `MyStruct` function.
Func(MyVar); //Sets his 'TestAliveVar' to 1
//and prints 'Still Alive!' with new line
delete(MyVar); //C++: free(MyVar);
Func(MyVar); //Does nothing
La pregunta es cómo crear la función.exists
Lo viste en este código. Por cierto puedo ejecutar códigos C ++ en este idioma.