Board index » delphi » using TstringLists in user defined objects

using TstringLists in user defined objects


2004-05-24 08:11:53 AM
delphi148
I try using a TStringlist as an object's attribute
But the "Create" doesn't work and i don't know where is the problem
voila le bout de code qui plante:
...
Groupe_mots = class(TPersistent)
private
{liste de chaine}
liste_mots : TStrings;
public
{le constructeur par défaut}
constructor Create;overload;
...
constructor Groupe_mots.create;
Begin
inherited Create;
liste_mots := TstringList.Create;{the problem is here}
End;
...
olivier
--
Using Opera's revolutionary e-mail client: www.opera.com/m2/
 
 

Re:using TstringLists in user defined objects

Quote
I try using a TStringlist as an object's attribute
But the "Create" doesn't work and i don't know where is the problem

constructor Create;overload;
I don't see any bugs in your constructor. What is your exact problem?
Why are you specifying "overload" for the parameterless Create
constructor? Do you have any other constructors? If you have other
constructors of which all parameters have default values Delphi may not
know which one to call.
 

Re:using TstringLists in user defined objects

On 23 May 2004 23:29:25 -0700, Avatar Zondertau
<XXXX@XXXXX.COM>writes:
Quote
>I try using a TStringlist as an object's attribute
>But the "Create" doesn't work and i don't know where is the problem
>
>constructor Create;overload;

I don't see any bugs in your constructor. What is your exact problem?

Why are you specifying "overload" for the parameterless Create
constructor? Do you have any other constructors? If you have other
constructors of which all parameters have default values Delphi may not
know which one to call.
yes, i have another constructor but without default parameter
and i have the same problem when using it.
the execution error message is like this
"EaccesViolation with the message "acces violation at the adress xxx in
the module 'project.exe'"..."
thanks for your answer
--
Using Opera's revolutionary e-mail client: www.opera.com/m2/
 

Re:using TstringLists in user defined objects

Quote
yes, i have another constructor but without default parameter
and i have the same problem when using it.

the execution error message is like this
"EaccesViolation with the message "acces violation at the adress xxx
in the module 'project.exe'"..."
This error is not caused by the code you posted. Please post more of
your code or a minimal example that reproduces the error if you run it
seperately.
 

Re:using TstringLists in user defined objects

Quote
This error is not caused by the code you posted. Please post more of
your code or a minimal example that reproduces the error if you run it
seperately.
i found my error, it is just a bad usage of contructor:
myinst : myobject;
myinst.Create
instead of
myinst : myobject;
myinst := myobject.Create;
--
Using Opera's revolutionary e-mail client: www.opera.com/m2/