If shape class is not an abstract class so it will not have any abstract member. Basically this will be like a instantiable class. But if you think on a conceptual plane, shape class itself does not have an identity.I mean if i say draw a shape you will
instantly ask what kind of shape should i draw,is it a circle, rectangle, triange or polygon.
So shape class happen to be meaning ful when it is inherited by a concrete class like circle. So when i say draw a circle you instantly draw a circle.
So abstract classes are used to manage the complexity of real world objects.
If will be all the same if your class is not an abstract class. But to let the polymorphism work the ColorShapes() method must be virtual so that it is overridden by child classes like Circle or Triangle. The previous code will keep running.
//Override to define the exact behaviour
public virtual void ColorShapes()
{
}
Hope i could make you understand.
Please “Mark as Answer” on the reply that helps you. This will help others jump directly to a solution having similar problem.
Pankaj.Sharm...
Contributor
2350 Points
387 Posts
Re: Polymorphism-which is faster and better
Apr 30, 2012 01:25 PM|LINK
If shape class is not an abstract class so it will not have any abstract member. Basically this will be like a instantiable class. But if you think on a conceptual plane, shape class itself does not have an identity.I mean if i say draw a shape you will instantly ask what kind of shape should i draw,is it a circle, rectangle, triange or polygon.
So shape class happen to be meaning ful when it is inherited by a concrete class like circle. So when i say draw a circle you instantly draw a circle.
So abstract classes are used to manage the complexity of real world objects.
If will be all the same if your class is not an abstract class. But to let the polymorphism work the ColorShapes() method must be virtual so that it is overridden by child classes like Circle or Triangle. The previous code will keep running.
//Override to define the exact behaviour public virtual void ColorShapes() { }Hope i could make you understand.