Specialties of the Init method

Description:

Even if the Init() method is a normal method, it has some special rules, since it is a constructor method.

 

Solution:

If any class has defined a method called “Init”, EmWi will call this method automatically after the initialization of all members. The Init() method must be defined with return type void and without arguments. For internal use, one int32 argument would be possible, but this should not be used by EmWi users.

 

If the Init() method is already defined in a super-class, we need to override the Init() method – BUT …

 

It is not necessary and even not allowed to do a super() call inside the Init() constructor, because the runtime environment takes automatically care, that the Init() constructor is called for all classes, starting from the top super-class down to the last derived class in the class hierarchy.

 

Usage: The Init() method is very convenient to attach slot method to an observer and to read out start values for the UI e.g.: a slider position or whether a checkbox is checked or not.

 

See also:

 

Keywords:

Constructor, Init

 

Last update on 2010-08-19 by Mario Stefanutti.

Go back