11-17-2010 06:20 PM
I have a item.lvclass which has an item.ctl (contains a cluster of class private data). I need to add another object (item2.ctl) within that same class so that I can reuse the code for that class.
So how do you create additional objects within the same class?
11-17-2010 06:37 PM
Well... right now... I've cornered myself going down this path: http://forums.ni.com/t5/LabVIEW-Idea-Exchange/LVOOP-Interfaces/idc-p/1314637#M8918
Seems like the solution in the idea was not implemented yet....
Okay. I will try to describe the situation differently...
Let's say I have a Car.lvclass
I want to have two objects: sedan & roadster
both have similar properties, but also have different properties:
4 doors vs 2 doors
hardtop vs convertible
silver vs white (color)
I want the two objects to be of the same class so that they can share the same private and public VI's. As a matter of fact, I want to have both objects in the VI's within the Car.lvclass.
11-17-2010 06:55 PM - edited 11-17-2010 07:05 PM
Why doesn't standard inheritance work?
Make a car class with Dynamic Dispatch Vis for
door count
top type
color
make a sedan class that inherits from car and override the Dynamic Dispatch VIs so
door count returns 4
top type retuns hardtop
color returns silver
make a roadster class that inherits from car and override the Dynamic Dispatch VIs so
door count returns 2
top type returns convertible
color returns white
For this example another option would be to put the door count, top type and color in the private data of the car class then make accessors with the write side having protected access. Then make sedan and roadster constructor vis that fill in the right defaults.
11-17-2010 07:16 PM
Actually, I may have poorly described my situation... I'm still learning LVOOP.
After a conversation with a friend, I discovered that I had not called the Create Object VI a second time to instatiate the 2nd object.
I will try that and post if that was the case.
Concerning the inheritance, those VI's exist... I could not get what I though was a 2nd object to inherit from the class because I had created another class intead of another object.... D'Oh!
11-18-2010 06:59 AM
It appears that was the case... I simply had to create a second object from that same class.
However, I'm still working on it. I'll see how it goes..