03-25-2020 04:30 AM
Good morning,
I'm pretty new to OOP in LabView (but I've already do it with other langages). I'm trying to do these classes in my project but I'm facing a problem, I can call the methods of the class "Voie" from her daughter Voie_AI_PT but when I try to call a method from a "grandchild", the method doesn't return anything (and I don't have any errors shown). Anyway, as soon as I try to call from above a parent method, I can't get a result and I don't know why.
Here is the inheritance of my classes:
And here is the scope of my method (which is the same for others). All my classes have public methods, I've tried with protected too but nothing changed.
I'm working on LabView 17.
Thank you for your help
Solved! Go to Solution.
03-25-2020 04:34 AM
Are you using the Call parent method or a direct call to the grandparents function?
/Y
03-25-2020 04:52 AM
I directly call the grand parent function, like this:
My grandparent class is made like this:
03-25-2020 05:17 AM
Hmm, that should work, and does so for me:
03-25-2020 05:32 AM
Oh, how or where can I check to resolve this ? Could it comes from the inheritance or a parameter I added or removed ? I chosed this inheritance parameters from my grandparent but I tried others things without success.
?
03-25-2020 05:37 AM
Do your accessors have Dynamic dispatch on the terminals?
/Y
03-25-2020 05:44 AM
Yes and all the childs have dynamic dispatch too (here is the ID getter from grandparent)
03-25-2020 05:53 AM
If you have the same method implemented in a child class, then calling the dynamic dispatch with the child object like you're showing will use the child implementation (even if you drop a grandparent node).
You could make 'Lire ID.vi' static dispatch (if you always want the grandparent to provide the value) or you can just not override it in children (but you can't always control middle classes in some arbitrary inheritance hierarchy).
The icon will update in the case that you're showing if a child class's method is being used, but the icons seem very similar so I can't tell if that's happening or not.
Also, you can use Context Help to see which VI will be called. Since you have a block diagram constant on the block diagram, it will give the "lowest" child that suits the hierarchy.
03-25-2020 06:06 AM
I found where the problem came from, it has nothing to do with inheritance. I just badly used my constructors in my first grand child so the grandparent data where sent in void.
Without you I would have searched in parameters instead of my code, thanks a lot for your help !