Assign constructor parameter to object variable - Delphi -


this question has answer here:

i keep getting error dialog:

access violation @ address xxxx in module 'xxxx.exe'. write of address xxxx.

what should do?

constructor tcustomclass.create(id: integer); begin   self.id := id; end; 

any thoughts?

the odds problem you're calling constructor incorrectly. you're doing similar following:

var   linstance: tcustomclass; begin   linstance.create(1);   ... end; 

the problem linstance doesn't exist yet, you're calling method on it. need create instance follows: linstance := tcustomclass.create(1);


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -