I recently attempted to Hide the Init method of a class to prevent it from being overridden. I wished to add a method that would be called from the Init method and would be overridable. I decided to verify that VFP6 would behave as expected.
I first created a class cstSuper as Custom with one method: InitChild() which I left empty. I overrode Init with:
?"Superclass Init."
This.InitChild()
and marked the Init method as Hidden.
Next I created a class cstChild as cstSuper and overrode the InitChild method with ?"Augmented.".
When I instantiated an instance of cstChild I expected to see:
SuperClass Init.
Augmented.
Instead I saw:
Augmented.
Then I changed InitChild to:
DODEFAULT()
?"Augmented."
and I saw:
SuperClass Init.
Augmented.
Now for the really strange part. I went back to cstSuper and changed the Init method to Public. When I opened cstChild and edited the Init method of cstChild I saw:
DODEFAULT()
?"Augmented."
which is the code from InitChild. I changed InitChild to ZInitChild and reran the tests with the same results. The only relationship between the methods that I can see, besides the fact that one calls the other is that the user defined method(InitChild, ZInitChild) comes first followed by the Init method in the method list seen in the code editor.
Can anyone else duplicate this behavior?. I am using VFP6 from the initial version of DevStudio 6. I could not reproduce this behavior in VFP5.
Ned.
Ned
Reality is.