Elktro Posted March 5, 2010 Report Share Posted March 5, 2010 Using SciWare's GOOP Developer 2.3 I have made ClassA and a child class B, which both have their own increment() virtual method. The base class method increments data member num by 1, and the B class increment data member num by 3. Both methods give incremented value as an output. The data member num has also a getter. I have made the demo below to illustrate my question. The two instances of the ClassA and B are called by their own implementation of increment and after incrementation num value is get. The base class ClassA part works as intended: num value is incremented and the value gotten from the increment method is the same as the value gotten from the getter. The child class B part, however, doesn't work the same way: the num value is incremented, but increment method return 0, although the getter shows that the value is indeed incremented in each loop execution. Here is the front panel after while loop has executed 3 times: So why the 0 output? Quote Link to comment
Elktro Posted March 5, 2010 Author Report Share Posted March 5, 2010 I found the problem! I just needed to wire output from the child implementation in the Descendant. (Dah!) It is so easy when you know it. Quote Link to comment
shoneill Posted March 5, 2010 Report Share Posted March 5, 2010 Without more code to go by this is just a guesstimate: Do you have a "num" field in both the parent and child? Could it be that you're setting the parent value and reading the child value or vise versa? Shane. Quote Link to comment
Elktro Posted March 5, 2010 Author Report Share Posted March 5, 2010 Do you have a "num" field in both the parent and child? Could it be that you're setting the parent value and reading the child value or vise versa? Yes, both should have num field as B class inherits it from its parent class classA, which has a num field. I don't quite see what you mean. How could the instances write each other's data members, if they are clearly in their own separate sequences? Quote Link to comment
Yair Posted March 6, 2010 Report Share Posted March 6, 2010 By the way, if you're using a more modern version of LV (8.2 and up), you should probably use LVOOP for handling inheritance. It's built-in and in active development, so it's easier to work with and understand. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.