LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parent Grandchild Inheritance - OOP

Solved!
Go to solution

Waking a thread from a perfectly good 7 year nap... I *think* I'm trying to the same sort of thing, but simpler.  When one downcasts a child class, but then the result is also needed on the grandparent class, does one do it the way I'm showing here?  Still very uncomfortably muddled about all this LVOOP business, I'm afraid.  Thanks! paul

0 Kudos
Message 11 of 15
(709 Views)

You might be better served by opening a new thread as it looked like the previous thread was mostly about getting data from a parent to a descendant, but you're just trying to load in a specific type without regard to the data contained within it.

 

Can I infer from the screenshot that you're trying to do an abstraction layer where you issue generic commands to a Controller and Motor and so if you wanted to switch to a different vendor of motion controller all the code except the device type would remain the same?

 

If so, what you're doing looks like it will work if all you're trying to get from the code is a type.  If you want to bring in any data, then that's more complicated.

0 Kudos
Message 12 of 15
(703 Views)

Good idea Kyle, will do.  I'll also flesh out my plan a bit later tonight

0 Kudos
Message 13 of 15
(697 Views)

 

It looks like you're using "To More Specific Class" when you cast from a specific child to a more generic parent.  You should use "To More Generic Class".  The parent is *more generic* than the child.

 

(I recall either a thread around here or a conversation with a colleague some years ago where it was found that one of those two functions worked correctly regardless of whether the cast was *actually* to more specific or to more generic.  But the other one didn't.  That's my memory of it anyway, I don't have code handy to test it out.)

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 14 of 15
(693 Views)

I'll take Kyle's suggestion and start a new thread (although this stuff is banging around all over the forum, I can't seem to get a clear enough picture.

0 Kudos
Message 15 of 15
(690 Views)