隨筆:25 文章:1 評(píng)論:8 引用:0
          BlogJava 首頁(yè) 發(fā)新隨筆
          發(fā)新文章 聯(lián)系 聚合管理

          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 閱讀(158) | 評(píng)論 (0)編輯 收藏
           
          用構(gòu)造函數(shù)定義屬性,用原型定義方法
          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);
          };
          在此例子中,繼承機(jī)制由兩行突出顯示的藍(lán)色代碼實(shí)現(xiàn)。在第一行突出顯示的代碼中,在 ClassB 構(gòu)造函數(shù)中,用對(duì)象冒充繼承 ClassA 類(lèi)的 sColor 屬性。在第二行突出顯示的代碼中,用原型鏈繼承 ClassA 類(lèi)的方法。由于這種混合方式使用了原型鏈,所以 instanceof 運(yùn)算符仍能正確運(yùn)行。

          下面的例子測(cè)試了這段代碼:
          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 閱讀(202) | 評(píng)論 (1)編輯 收藏
           
          做個(gè)查詢(xún),字段1值除3,如果=1,就用字段2值-20,如果=2,字段2 值-30,將差值大于0的數(shù)據(jù)選出來(lái)?

          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 閱讀(301) | 評(píng)論 (0)編輯 收藏
          CALENDER
          <2007年1月>
          31123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          常用鏈接

          留言簿(1)

          隨筆分類(lèi)

          隨筆檔案

          相冊(cè)

          收藏夾

          朋友blog

          最新評(píng)論


          Powered By: 博客園
          模板提供滬江博客

          Contact ljwiie QQ:122050271
          主站蜘蛛池模板: 普宁市| 英吉沙县| 嘉善县| 吉安县| 全椒县| 金寨县| 内丘县| 石渠县| 营口市| 平舆县| 合作市| 梅河口市| 齐河县| 荆门市| 正安县| 万州区| 子洲县| 陇西县| 萨迦县| 通道| 朝阳区| 涿州市| 小金县| 内江市| 闵行区| 榆林市| 尼玛县| 聊城市| 石阡县| 锡林郭勒盟| 华容县| 临漳县| 东方市| 南通市| 柘城县| 临泽县| 巴彦淖尔市| 北流市| 无极县| 昌黎县| 东乌珠穆沁旗|