1.工厂模式:及时由一个工厂类根据传入的参数决定生产那种产品类function
createPerson(name,age,job){ var o = new Object(); o.name = name; o.age = age;
o.job = job; o.sayName = functio...
分类:
编程语言 时间:
2014-05-10 02:11:47
阅读次数:
423
静态成员变量可以使用类名调用,如class Dog{ static int age;
}class Test2{ public static void main(String args[]){ Dog.age=10; //类名调用
}}也可以用调用普通成员...
分类:
编程语言 时间:
2014-05-09 12:09:04
阅读次数:
381
1:默认初始化如果对类中的变量不进行初始化,系统则会初始化变量为对应的值 比如int = 0,
bool = fase String = null;2:手动初始化变量private int age = 23;3:初始化块{ id = 201245; age
= 23;}4:构...
分类:
编程语言 时间:
2014-05-08 12:57:43
阅读次数:
361
一
jQuery的扩展方法原型是$.extend(dest,src1,src2,src3);含义是将src1,src2,src3合并到dest中,返回值为合并后的dest,该方法合并后,dest的结构被修改.结果:Object
{ type="person", name="lisi", age=.....
分类:
Web程序 时间:
2014-05-07 14:26:24
阅读次数:
358
优先级操作符描述例子结合性1()[]->.::++--调节优先级的括号操作符数组下标访问操作符通过指向对象的指针访问成员的操作符通过对象本身访问成员的操作符作用域操作符后置自增操作符后置自减操作符(a
+ b) / 4;array[4] = 2;ptr->age = 34;obj.age = 34;...
分类:
编程语言 时间:
2014-05-07 09:45:56
阅读次数:
396
js中处处是对象,面向对象的第一步当然就是封装了,由于Js中没有类的概念,所以封装起来也比较麻烦,下面介绍两种js的封装。
1、使用约定优先的原则,将所有的私有变量以_开头
/**
* 使用约定优先的原则,把所有的私有变量都使用_开头
*/
var Person = function (no, name, age)...
分类:
编程语言 时间:
2014-05-07 08:30:05
阅读次数:
411
这篇对应的是习题39 字典, 可爱的字典
#encoding:utf-8
#列表与字典的区别
#列表
thing = ['name',1,'age','AD','sex']
print thing[1]
#print thing['name'] #会报错,列表只能通过整数去访问:TypeError: list indices must be integers, not str
stuff...
分类:
编程语言 时间:
2014-05-07 06:00:20
阅读次数:
365
Birthday Candles
The chef is preparing a birthday cake for one of his guests,
and his decided to write the age of the guest in candles on the cake.
There are 10 types of candles, one for each o...
分类:
其他好文 时间:
2014-05-04 18:46:55
阅读次数:
416
OC点语法和变量作用域一、点语法(一)认识点语法声明一个Person类: 1 #import 2 3
@interface Person : NSObject 4 { 5 int _age;//默认为@protected 6 } 7 8 -
(void)setAge:(int)age;...
分类:
其他好文 时间:
2014-05-04 10:25:07
阅读次数:
311
基于原型的创建虽然可以有效地完成封装,但是依然存在如下问题:
1.无法通过构造函数来设置属性值
2.当属性中有引用类型变量时,可能存在变量值重复
function Person(){
}
Person.prototype = {
constructor:Person,
name:"Leon",
age:30,
friends:["Ada","Chris"],...
分类:
Web程序 时间:
2014-05-04 09:15:22
阅读次数:
328