Usually the reason is polymorphism. If, for example, the Dimensions 'c'
variable is later assigned to another instance, that is *not* a circle but
is still a Dimensions... then you would do it.
I think in that particular example on MSDN, they were just demonstrating
polymorphism and that's why they chose to declare the type as Dimensions.
--
John Wood
Blog:
http://spaces.msn.com/members/johnwood/
"Mark Bremmer" <Mark
(E-Mail Removed)> wrote in message
news:30BCCE51-1F91-40DA-9FCB-(E-Mail Removed)...
> I've been reading about virtual functions and I keep seeing code like this
in
> the examples:
>
> Dimensions c = new Circle(r);
>
> The Circle class is derived from Dimensions class.
>
> I understand the benefits of inheritance but I don't understand why you
> would declare a circle as a Dimensions class. This seems to be a common
> practice, too. The following three articles from MSDN all do it but I
don't
> understand why. Are they just trying to demonstrate which method would be
> called under these special declaration circumstances?
>
>
> Why not do this:
>
> Circle c = new Circle(r);
>
>
> 1)
>
http://msdn.microsoft.com/library/de...fvirtualpg.asp
> 2)
>
http://msdn.microsoft.com/library/de...ngtutorial.asp
> 3)
>
http://msdn.microsoft.com/library/de...pec_10_5_3.asp