874 views
in GUI Development by
Hello,

I want to pass some parameters when calling the constructor new for a component, so those parameters get used in the initialization of the component, where those parameters are properties of the component

Example :

new Application::ReceiptProgam ( numOfProgram,NameOfProgram) ;

Creates the object ReceiptProgam with properties itialized with values numOfProgram,NameOfProgram;

1 Answer

+1 vote
by
 
Best answer

Hello Riccardo,

passing arguments in Init() method is not possible. The recommended approach is to implement a dedicated initialization method, which after performing the initialization returns this. For example:

Then to create a new object of the class and initialize it with the desired arguments, you perform following or similar code:

var Application::Data data = (new Application::Data).Initialize( 1, 2 );

I hope it helps you further.

Best regards

Paul Banach

by

i want to do this in an Array but i get this error

 

edit: i have to put Application::ReceiptList in the return of the function

by

Hello Riccardo,

edit: i have to put Application::ReceiptList in the return of the function

yes, the return type of such 'initilaization' method has to correspond to the class of the object. Does it mean, you solved the issue?

Best regards

Paul

by
Yes, thanks that was the intent.

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...