zoukankan      html  css  js  c++  java
  • initial class tcl tk

    class Singleton {
           private common _instance {}  ;# static instance variable

           #
           # Define a "static method" Instance.
           #
           proc Instance {} {
               if { $_instance == {} } {
                 set _instance [Singleton ABC]
                  }
           return $_instance
           }
           # end of Instance
           constructor {} {
              set caller [info level [expr [info level] - 1]]
             if ![string match "Singleton::Instance" $caller] {
                   error "Class Singleton can not be directly instantiated - use Instance"
               }

          }

    }

    set s [Singleton::Instance]

    set bb [Singleton::Instance]

    ==============================================


    class Singleton {
           private common _instance {}  ;# static instance variable
           constructor {} {
        if { $_instance == {} } {
            set _instance onlyone
        } else {
            error "Class Singleton already instantiated"
        }
           }
       }

    Singleton ab                 (right)
    Singleton cd                 (wrong)

  • 相关阅读:
    116. 跳跃游戏
    182. 删除数字
    unity判断LayerMask里面是否包含你想要的Layer
    Unity Animator自动连线
    Behavior designer 行为树插件 笔记
    unity2d 完美斜坡方案
    youtube 油管视频带字幕下载
    unity资源提取工具AssetStudio
    ugui 通用页签管理器
    unity拓展编辑器入门
  • 原文地址:https://www.cnblogs.com/greencolor/p/2046843.html
Copyright © 2011-2022 走看看