public abstract class Shape { //...Class implementation public abstract void Draw(int x, int y) { //this method mustn't be implemented here. //If we do implement it, the result is a Syntax Error. } } public abstract class Shape2D : Shape { //...Class implementation //...you do not have to implement the the method Draw(int x, int y) } public class Cricle : Shape2D { //here we should provide an implemetation for Draw(int x, int y) public override void Draw(int x, int y) { //must do some work here } }
Shape m_MyShape = new Shape(); //it is Wrong to that.
Shape m_MyShape = new Circle(); // True
Shape m_MyShape; /* declare refrences only, and the refrences can refer to intances of any concrete classes derived from abstract class */ Circle m_MyCircle = new Circle(); m_MyShape = m_MyCircle; // Also True
Build Your Own ASP.NET Website Using C# & VB.NET