var cc = new Class({
    name:'Tz',
    say:function(){
        alert('hi,world');
    },
initialize:function(){ alert("init");}
}
);var gg = new cc();
alert(cc.song);
alert(cc.constructor);

解决方案 »

  1.   

    var cc = new Class({
        name:'Tz',
        say:function(){
            alert('hi,world');
        }
    }
    );var gg = new cc   ====》   cc.song();
      

  2.   

    var gg = new cc(); 返回的是
    var _class = function(){return (arguments[0] !== null && this.initialize &&typeof(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;};
    中的this;这个this 是指的是 function(){return (arguments[0] !== null && this.initialize &&typeof(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;};它没有song函数。
      

  3.   

    这个问题 现在才弄的完全明白:var _class = function(){return (arguments[0] !== null && this.initialize &&typeof(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;};utils.extend(_class,this); //这个 地方我认为是_class添加Class类中的方法 ,但是却没有成功啊。。这里面的继承,是指 _class 继承。如果  var t = new _class(); 这是里的t是不会继承的。    因为这是new 了一个,就是新开辟了一个内存。    
      

  4.   

    <script type="text/javascript">
    var utils = {};
    utils.extend = function()   
    {
        var args = arguments;
        if(!args[1])args = [this,args[0]];                                          
        for(var property in args[1])args[0][property] = args[1][property];            
        return args[0];
    };var Class = function(properties){
        var _class = function(){return (arguments[0] !== null && this.initialize &&typeof(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;};
        utils.extend(_class,this); //这个 地方我认为是_class添加Class类中的方法 ,但是却没有成功啊。。          
        _class.prototype = properties;     
        if(properties.name)
        {
            var family = properties.name.toLowerCase();
            _class.prototype.$family = {name : family};  
        };
        _class.constructor = Class;  //这个地方不是明白,是给_class添加一个Class类的方法吗       
        return _class;
    };Class.song=function(){
    alert('wo are pest!')
    }var cc = new Class({
        name:'Tz',
        say:function(){
            alert('hi,world');
        }
    }
    );var gg = new cc
    // gg.song()                有错误,因为不能获得该方法
    //for(var i in gg)
     //{alert(i);alert(gg[i])} 便利后 没有发现_class.constructor这个方法</script>