It contains inheritance in the form of basecalss->derivedclass1->derivedclass2
Same function defined in all classes.
File 1: Virtual_override_override.cs
Functional is virtual in parent class while override in both classes "derivedclass1" and "derivedclass2".
It is condition that for override, virtual should be present.
When parent class "basecalss" refers to child class "derivedclass1", output is ok because virtual is present in "basecalss", override is present in "derivedclass1".
When parent class "basecalss" refers to grand child class "derivedclass2", output is confusing because this class "derivedclass2" there is override function but corresponsing virtual is not present in class "derivedclass1".
Is this behaviour ok i.e. if child is overridden and grandchild is also overridden? what's the reason.
---------------------------------------------------------------------
File 1: Virtual_virtual_override.cs
Functional is virtual in parent class and in child classe "derivedclass1" but override in "derivedclass2".
It is condition that for override, virtual should be present.
When parent class "basecalss" refers to child class "derivedclass1", output is ok because virtual is present in "basecalss", override is not present in "derivedclass1".
When parent class "basecalss" refers to grand child class "derivedclass2", output is confusing because this class "derivedclass2" there is override function and corresponsing virtual is also present in class "derivedclass1".
Is this behaviour ok i.e. if child is not overridden but grandchild is overridden? what's the reason.
-------------------------------------------------------------
Code C# |
So main question is that when parent refers to any child class or grand child, how virtual-overrides are mapped

Master BillaRank #2,229 · 630 reputationPosted Aug 21, 2009, 1:18 AM EDT
Just look at this simple sample
http://bartdesmet.net/blogs/bart/archive/2006/09/24/4467.aspx
thank you