mane Posted August 23, 2007 Report Share Posted August 23, 2007 I have a "listSpec" class which is part of some reuse code which contains properties in a name/value format. In a certain utility I need additional functionality for the listSpec class. So I created an "analyzeSpec" class which inherits from the listSpec class. In my utility I load a file which creates the listSpec objects(this is the reuse code). I would then like to convert the listSpec objects into analyzeSpec objects to extend their functionality. I need the runtime value of the listSpec objects to be transfered to the analyzeSpec objects. I tried to use the "to more specific" class function. It compiles correctly, but generates a runtime error stating "LabVIEW: Bad type cast. LabVIEW cannot treat the run-time value of this LabVIEW class as an instance of the given LabVIEW class." Does anybody know how I can achieve my original goal of generating analyzeSpec objects from listSpec objects while maintaining the runtime value of the original listSpec objects? Or am I in a completely wrong neighborhood and should try a different implementation method???? Quote Link to comment
MikaelH Posted August 23, 2007 Report Share Posted August 23, 2007 You have to start by creating the child object (analyzeSpec), but you can then of cause use it as it was a normal listSpec object, but now you have the option to use the childs methods as well. To be able to convert it from a base to a child in runtime is not allowed, maybe it will be some day. See Wish List , Post 8- //Mikael Quote Link to comment
Aristos Queue Posted August 23, 2007 Report Share Posted August 23, 2007 mane: Here's the post that covers specifically what you're doing: http://forums.lavag.org/index.php?showtopi...ost&p=34203 QUOTE To be able to convert it from a base to a child in runtime is not allowed, maybe it will be some day. No, it won't be allowed someday. As I explained in the other thread, that would be a major violation of encapsulation to provide such a generic casting mechanism. You're free to write such a conversion tool (as shown in the post above) for making children out of parents. But LV (nor any other OO language) will never provide such functionality directly. (Again, see the other thread for details about why.) 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.