06-19-2012 08:56 AM
Let's assume in an hypothetical example that I have a parent class (number) with two children classes (real and complex).
I would like to define a sum function for these classes, using dynamic dispatch.
Both real and complex would have its own sum method (VI) that would perform different operations, as real and complex numbers are different beasts.
If I understood correctly, the normal way to do this in OOP is for each of these methods to have one dynamic dispatch input, and a static input of its own type.
Problem: Labview won't let me do this !
I first define a dummy dynamic-dispatch input method for the parent class number, but only the first input can be dynamic-dispatched so the second one is statically typed as number.
Then, when I create override methods in my two children classes real and complex, the second (static) input stays as number (the type of the parent class). This is not right, because then I cannot access the private data of the child class of type real or complex that will be wired to the second (static) input.
What is the usual solution to this (usual) problem ?
Solved! Go to Solution.
06-19-2012 01:18 PM
@calvintiger wrote:
...
What is the usual solution to this (usual) problem ?
Use a variant as the input/output?
Ben
06-19-2012 02:35 PM
I think in LVOOP you only use a dynamic terminal or a static terminal for the object terminal.
You can have multiple other terminals, but all the dynamic VI's ( methods with same name) must have the same API ( Terminals ).
So you have to figure out your preferred method to pass, use multiple terminals, not used by each method, or use a cluster that contains all the numbers to be passed in ( real or complex, both not used in each method) or you could try a variant, as mentioned.
06-20-2012 04:13 AM
Thanks to all for your answers.
It made me think: wouldn't it be simpler to use a "to more specific class" node ?