Introduce Composition Relationships Into an Object-Oriented Program Within LabVIEW

Updated Dec 18, 2018

Reported In

Software

  • LabVIEW

Issue Details

I have a situation where I want to have a class within another class. In other languages, we would have composition. Is it possible to implement this relationship in LabVIEW?

Solution

In order to set up composition in LabVIEW you simply need to drag the class you want to include into the data cluster of another class. 

Please see the below image for an example of composition. In this image, we have three classes: A Car, Wheel and Engine. We would like to have the Wheel and Engine as part of the Car class. In order to implement this we have dragged the relevant classes directly into the data cluster for the Car class. This has formed our composition relationship. We can later 'Unbundle' the object from the containing one when we need to specifically access it.