Classes and Objects

LabVIEW 2018 Help

Edition Date: March 2018
Part Number: 371361R-01
View Product Info

DOWNLOAD (Windows Only)

LabVIEW 2016 Help
LabVIEW 2017 Help
LabVIEW 2018 Help
LabVIEW 2019 Help
LabVIEW 2020 Help

In object-oriented programming, classes represent general traits that items share. You can visualize a class, generically, as a vehicle. Vehicles share common traits and the class defines those traits. An object is a specific occurrence of a class. An object of a vehicle class can be the specific car you drive. The class definition determines how your car, the object, behaves.

A class defines the data and methods associated with an object of the class. Continue to use a vehicle as an example. Many vehicles exist in the world. You can generically classify all types of cars, trucks, and buses as vehicles. Vehicles have doors on the body and gears in the transmission. Information about the number of doors and number of gears in the transmission is data about the vehicle. Vehicles also can accelerate and brake. Accelerating and braking are behaviors, or methods, of the vehicle. The data and methods associated with the vehicle define the class Vehicle. You create classes to define the data and methods of the object. The following image displays the LabVIEW class representation of class Vehicle. LabVIEW stores the data of class Vehicle in Vehicle.ctl and the methods of Vehicle in VIs named Start Vehicle VI and Stop Vehicle VI.

An object is a specific instance of a class. The vehicle that you drive is a specific implementation of class Vehicle, or an object of class Vehicle. The following block diagram of Main VI displays an object of class Vehicle. Objects have data and methods defined by the class. LabVIEW stores class data in a control and you create member VIs that are the methods of the LabVIEW class.

For the purpose of conceptualizing the uses for LabVIEW object-oriented programming, you can differentiate users of LabVIEW classes in the following manner:

  • LabVIEW class developer—Develops LabVIEW classes for other developers and programmers to use. The LabVIEW class developer likely has prior experience in object-oriented programming. The LabVIEW class developer needs to understand the LabVIEW class and its mechanics.
  • LabVIEW class user—Uses the LabVIEW classes the LabVIEW class developer creates. The LabVIEW class user can take advantage of the benefits of object-oriented programming but does not need to know the mechanics of how the class works to use it in his or her application and may have no previous experience with object-oriented programming. The LabVIEW class user might not have access to the internal operations of the class after the LabVIEW class developer distributes the class. The changes a LabVIEW class developer makes to a LabVIEW class should have minimal impact to the applications developed by LabVIEW class users.

The LabVIEW class user does not need to know how to create a LabVIEW class, but rather how to use the data type a class defines in an application, what information is available to them in debugging code that uses LabVIEW classes, and how a new version of the LabVIEW class might affect the application the programmer has built. If you are using LabVIEW classes only and are not developing them, refer to the Using LabVIEW Classes in an Application topic for specific information about using LabVIEW classes another developer provides you.


Not Helpful