zoukankan      html  css  js  c++  java
  • AutoCAD.Net/C#.Net QQ群:193522571 虚拟方法的使用

    shell类中有一个虚方法;

    而其子类Cylinder、Head及其子类中去实现此虚方法;

    这样,在其它类如Main类中可以通过shell及其子类的实例来调用此虚方法;

    如:new 一个HeadEllipse  EH

    用方法Draw(EH)来实现;

      public class Main
      {
      
    public void Draw(Shell shell) { shell.Draw(); } } public class Shell : Part { public virtual ObjectId Draw() { return ObjectId.Null; } } public class Cylinder : Shell { public override ObjectId Draw() { int identify = this.GetCurrentPartIdentity<Cylinder>() + 1; ObjectId id = Draw(identify); this.SetCurrentPartIdentity<Cylinder>(identify); return id; } } public class Head : Shell { } public class HeadEllipse : Head { public override ObjectId Draw() { int identify = this.GetCurrentPartIdentity<HeadEllipse>() + 1; ObjectId id = Draw(identify); this.SetCurrentPartIdentity<HeadEllipse>(identify); return id; } } public class HeadDished : Head { public override ObjectId Draw() { int identify = this.GetCurrentPartIdentity<HeadDished>() + 1; ObjectId id = Draw(identify); this.SetCurrentPartIdentity<HeadDished>(identify); return id; } }
  • 相关阅读:
    自己建二维obj
    微信webview
    闭包
    angular
    2015项目timeline
    项目总结
    aa
    AHA高级心血管生命支持ACLS课前自我评估测试
    BASH_SOURCE
    bootstrap--小李子demo
  • 原文地址:https://www.cnblogs.com/swtool/p/14220352.html
Copyright © 2011-2022 走看看