随笔:25 文章:1 评论:8 引用:0
BlogJava 首页 发新随笔
发新文章 联系 聚合管理

2007年1月11日

for a C++ program converts true and false to 1 and 0 where integer values are expected, and it converts 0 to false and nonzero to true where bool values are expected.
posted @ 2010-05-22 00:23 ljwiie 阅读(148) | 评论 (0)编辑 收藏
 
用构造函数定义属性,用原型定义方法
function ClassA(sColor) {
    this.color = sColor;
}

ClassA.prototype.sayColor = function () {
    alert(this.color);
};

function ClassB(sColor, sName) {
    ClassA.call(this, sColor);
    this.name = sName;
}

ClassB.prototype = new ClassA();

ClassB.prototype.sayName = function () {
    alert(this.name);
};
在此例子中,继承机制由两行突出显示的蓝色代码实现。在第一行突出显示的代码中,在 ClassB 构造函数中,用对象冒充继承 ClassA 类的 sColor 属性。在第二行突出显示的代码中,用原型链继承 ClassA 类的方法。由于这种混合方式使用了原型链,所以 instanceof 运算符仍能正确运行。

下面的例子测试了这段代码:
var objA = new ClassA("blue");
var objB = new ClassB("red", "John");
objA.sayColor(); //输出 "blue"
objB.sayColor(); //输出 "red"
objB.sayName(); //输出 "John"

摘自http://www.w3school.com.cn/js/pro_js_inheritance_implementing.asp
posted @ 2010-05-06 23:57 ljwiie 阅读(194) | 评论 (1)编辑 收藏
 
做个查询,字段1值除3,如果=1,就用字段2值-20,如果=2,字段2 值-30,将差值大于0的数据选出来 

SELECT col1, col2, 
CASE 
   WHEN col1 / 3 = 1 THEN col2 - 20 
   WHEN col1 / 3 = 2 THEN col2 - 30
END AS difference
FROM price
WHERE (
CASE 
   WHEN col1 / 3 = 1 THEN col2 - 20 
   WHEN col1 / 3 = 2 THEN col2 - 30
END > 0)
posted @ 2007-01-11 10:26 ljwiie 阅读(291) | 评论 (0)编辑 收藏
CALENDER
<2007年1月>
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用链接

留言簿(1)

随笔分类

随笔档案

相册

收藏夹

朋友blog

最新评论


Powered By: 博客园
模板提供沪江博客

Contact ljwiie QQ:122050271