zoukankan      html  css  js  c++  java
  • pass args to parent

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

      class parent {
          public variable parent_a "";
          public variable parent_b "";

          constructor { args } {

       puts stdout "parent this -$this- args -$args-"
       eval configure $args
       # check value of parent_a
       if { $parent_a == "" } {
           puts "--> bad parent_a"
       }
          }
      }

      class child {
          inherit parent
        
          public variable child_a

          # pass arguments in an init code fragment
          constructor { args }  {
       puts stdout "child this -$this- args -$args-"
       eval configure $args
          }
      }

      child testobj -child_a "val_child_a" -parent_a "val_parent_a"

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


      class parent {
          public variable parent_a "";
          public variable parent_b "";

          constructor { args } {

       puts stdout "parent this -$this- args -$args-"
       eval configure $args
       # check value of parent_a
       if { $parent_a == "" } {
           puts "--> bad parent_a"
       }
          }
      }

      class child {
          inherit parent
        
          public variable child_a

          # pass arguments in an init code fragment
          constructor { args } {
              eval parent::constructor $args
          } {      
       puts stdout "child this -$this- args -$args-"
       eval configure $args
          }
      }

      child testobj -child_a "val_child_a" -parent_a "val_parent_a"

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

  • 相关阅读:
    命令执行顺序控制与管道
    js获取返回首页
    手机站点击商务通无轨迹解决方法
    js文字向上滚动代码
    文字隐藏多余的文字
    QQ弹窗代码
    百度推送代码
    js手机站跳转
    js 判断时间,满足执行框架
    js切换换class
  • 原文地址:https://www.cnblogs.com/greencolor/p/2129020.html
Copyright © 2011-2022 走看看