
Punteros
Publicado por thenine (6 intervenciones) el 20/04/2007 11:32:47
Hola a todos,
tengo el siguiente código y al hacer un dispose() de un puntero lo elimina de memoria,
Si es así por que si hago el writeln() en la última linea me escribe el valor que tiene,
despues de haber echo el dispose() no lo ha liberado y con lo cual debería desaparecer???
me podeís ayudar a entnderlo
Salu2
Type
TRegistro=RECORD
articulo:String;
precio:integer;
END;
TPRegistro=^TRegistro;
var
dato:integer;
ref1,ref2,ref3:TPRegistro;
begin
new(ref1);
new(ref2);
new(ref3);
ref1^.articulo:='pan';
ref1^.precio:=50;
ref2^.articulo:='leche';
readln(ref2^.precio);
ref3^.articulo:=ref1^.articulo + ',' + ref2^.articulo;
ref3^.precio:=ref1^.precio+ref2^.precio;
writeln(ref3^.articulo,' ',ref3^.precio);
dispose(ref1);
writeln(ref1^.precio);
end
tengo el siguiente código y al hacer un dispose() de un puntero lo elimina de memoria,
Si es así por que si hago el writeln() en la última linea me escribe el valor que tiene,
despues de haber echo el dispose() no lo ha liberado y con lo cual debería desaparecer???
me podeís ayudar a entnderlo
Salu2
Type
TRegistro=RECORD
articulo:String;
precio:integer;
END;
TPRegistro=^TRegistro;
var
dato:integer;
ref1,ref2,ref3:TPRegistro;
begin
new(ref1);
new(ref2);
new(ref3);
ref1^.articulo:='pan';
ref1^.precio:=50;
ref2^.articulo:='leche';
readln(ref2^.precio);
ref3^.articulo:=ref1^.articulo + ',' + ref2^.articulo;
ref3^.precio:=ref1^.precio+ref2^.precio;
writeln(ref3^.articulo,' ',ref3^.precio);
dispose(ref1);
writeln(ref1^.precio);
end
Valora esta pregunta


0