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

php - How to display all orders for a single product showing the most recent first? Woocommerce -

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

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -