BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pointer problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal
View previous topic :: View next topic  
Author Message
luisgutierrezb@gmail.com
Guest





PostPosted: Sat Jul 23, 2005 2:11 pm    Post subject: pointer problem Reply with quote



Hi, everyone.
excuse my english...

i try this:

type
PunteroDatos = ^Datos;
Datos = Record
Dato:String;
Anterior: PunteroDatos;
Siguiente: PunteroDatos;
End;

Type
TLista = Class(TObject)
Private
Primero, Ultimo, Actual, ArregloDatos: PunteroDatos; // first,
last, actual position
Function AgregaElemento(Elemento: PunteroDatos):Boolean; //add new
element
Public
Function AgregaDatos(Dato1: String): Boolean; //add new element
...
...
end;


Function TLista.AgregaDatos(Dato1: String): Boolean;
Begin
New(ArregloDatos); <---- here! raise a exception
ArregloDatos^.Dato := Dato1;
Result := AgregaElemento(ArregloDatos);
End;

the question is why¿? raise a exception

but, if i delete "ArregloDatos" and declare this in fuction:
Function TLista.AgregaDatos(Dato1: String): Boolean;
Var
ArregloDatos: PunteroDatos;
Begin
New(ArregloDatos);
ArregloDatos^.Dato := Dato1;
Result := AgregaElemento(ArregloDatos);
End;


then, works fine...

Back to top
Riki Wiki
Guest





PostPosted: Thu Jul 28, 2005 11:06 pm    Post subject: Re: pointer problem Reply with quote



Hoi Luis

Take a look here:
http://delphi.wikicities.com/wiki/Delphi_Newsgroups
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.