G
Guest
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/default.asp?url=/library/en-us/csref/html/vclrfvirtualpg.asp
2)
http://msdn.microsoft.com/library/d.../en-us/csref/html/vcwlkversioningtutorial.asp
3)
http://msdn.microsoft.com/library/d.../en-us/csspec/html/vclrfcsharpspec_10_5_3.asp
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/default.asp?url=/library/en-us/csref/html/vclrfvirtualpg.asp
2)
http://msdn.microsoft.com/library/d.../en-us/csref/html/vcwlkversioningtutorial.asp
3)
http://msdn.microsoft.com/library/d.../en-us/csspec/html/vclrfcsharpspec_10_5_3.asp