ç¥ããªãã¨æ¥ããã ããã°ã©ãã³ã°ã®å¸¸è
- ä½è : æ¥åä¿äº
- åºç社/ã¡ã¼ã«ã¼: ã¢ã¹ãã¼ã»ã¡ãã£ã¢ã¯ã¼ã¯ã¹
- çºå£²æ¥: 2009/02/25
- ã¡ãã£ã¢: åè¡æ¬ï¼ã½ããã«ãã¼ï¼
- ã¯ãªãã¯: 108å
- ãã®ååãå«ãããã° (8件) ãè¦ã
ã¡ã¼ã«ã¢ãã¬ã¹ãè¼ã£ã¦ããããåé¡ç¹ãã¾ã¨ãã¦*1éã£ãããæå¤ã¨æ©ãè¿ä¿¡ãæ¥ããã®ã®ã»ã»ã»ã»
ç§ã®èãæ¹ã¯223ãã¼ã¸ä»¥éã«è¨ããã¨ããã§ãã
ä¸é¨ããææã®ãã¨ãè¸ã¾ãã¦ãå°æ¥ã®çã§ããé©åã«æ¸ãç´ããã¨ãæ¤è¨ããã¦ããã ãããã¨æãã¾ãã
æ¬æ¸ã®åºçããä»ã®ãããã°ã©ãã³ã°ã®å¸¸èãã«é¢é£ããæ¸ç±ã®å 容ã®æ¯è¼çãå«ãã¦ãæ´»çºãªè°è«ã®ãã£ããã«ãªãã°å¹¸ãã§ãã
äºé¿ç¸ç ããããããã
ãªãè°è«ã®ãã£ããã«ãªãããã«ããä¸é¨ãã§ã¯ãªãã£ããã¨ã示ãã¦ãããã¨ã«ããã*2 *3ã
223 ãã¼ã¸ã®ãç§ã®èããã¯ã©ããªãã®ãã¨ããã¨ã
æ¬æ¸ã§ã¯ãã¾ãã¾ãªããã°ã©ãã³ã°è¨èªãããã°ã©ãã³ã°ç°å¢ãåãä¸ãã¦ãã¾ãããè¨èªãç°å¢ã«ãã£ã¦æ£å対ã®ãã¨ãããã«ããããããããã¾ãã¾ãªãããã¯ã大èä¸æµã«åãä¸ããã®ã«ã¯ããã¡ããçç±ãæ ¹æ ãããã¾ãã
一般的で原則的な話
ã»ã»ã»
æ¬æ¸ãèªãã§ãã¦ããããã¯ééã£ã¦ããããããªãã ãããï¼ãã¨æã£ã人ãããããããã¾ããã
å®éã«ãæ¬æ¸ã®è¨è¿°ã®ä¸ã«ã¯ç¹å®ã®ç°å¢ãç¹å®ã®ããã°ã©ãã³ã°è¨èªã«ã¯ãã¦ã¯ã¾ããªããã¨ãè¨ãæããã°ç°å¢ãããã°ã©ãã³ã°è¨èªã«ãã£ã¦ã¯ééãã§ãããã¨ã (å°ãã¯) ããã¾ãã
ã»ã»ã»
ãããããããã¨ãæ¬æ¸ã®ã»ã¨ãã©ã®æ®µè½ã§ãä¸è¬çã«ã¯ãããååã¨ãã¦ãããããã¯ããå¤ãã®å ´åã«ã¯ãã¨ããä¸è¬ã«è¯ã使ããã¦ããéçºç°å¢ã§ã¯ããªã©ã使ããã¨ã«ãªããã»ã»ã»ããã§ãæ¬æ¸ã§ã¯ãã¡ãã¡ãä¸è¬çã«ã¯ãããååã¨ãã¦ãã¨æã£ã¦ãã¾ããã
ã»ã»ã»
èªåã®å¸¸èã¯ä¸éã®å¸¸èã¨ã¯å¿ ãããä¸è´ããªãã¨ãããä¸éä¸è¬ã§ãå½ããåã§ãããªããå¿ããããã¡ãªãã¨ã常ã«å¿ããªãããã«ããå¿ è¦ãããã¾ã
ã»ã»ã»
ããã°ã©ãã³ã°ãç¿å¾ãã¦ããç¨åº¦çµé¨ãç©ãã¨ããã¡ãã¡æ¤è¨¼ããã«ãããã¾ã§ã®èªåã®çµé¨ã¨ç¥èã§å¤æããããã«ãªãã¾ããããã®ãããªã¨ãã«ç¬æãåè¦ãæã¡è¾¼ã¾ãªãããã«å¸¸ã«æ°ãã¤ããå¿ è¦ãããã¾ã (èè èªæ)ã
ããã¨ä¸ã®ã¡ã¼ã«ã®å 容ãè¸ã¾ãã¦ä»¥ä¸ããèªã¿ãã ãã (é·æ注æ)ã
å®å ¨ã«ééã£ã¦ãããã®
åè«ã®ä½å°ã¯å ¨ããªããå®å ¨ã«ééã£ã¦ããé¨åã
ãã¯ã
ãµãã«ã¼ãã³ã®å¼ã³åºãã«ã¯ãªã¼ãã¼ãããããããã¨ã«è§¦ãããã®ãªã¼ãã¼ãããããªãããã¨ã®ã§ããæ段ã¨ãã¦ãã¯ããç´¹ä»ãã¦ãããããã®ãã¯ãã
#define add2val(m, n) (m + n)
サブルーチンかマクロか (P.27)
ã¨ããã°ãå«ãã§ããã
ãã®ãã¯ãã
int result = add2val(1 << 2, 3);
ã®ããã«ä½¿ç¨ããã¨ã
int result = (1 << 2 + 3);
ããå±éããããã<< ã®åªå
é ä½ã + ã®åªå
é ä½ãããä½ãããã7 ã§ã¯ãªã 32 ã¨ãªãã
åãããããæ¬å¼§ãä»ããã¨ã
int result = (1 << (2 + 3));
ããã
ã§ãæ¬æã§ã¯ãã¯ãã®ããããå±éºæ§ã«ã¤ãã¦ã¯ã
ãã¯ãã¯æååã®ç½®æã§å®ç¾ããã¦ããã®ã§ã注æãæããªãã¨äºæããªãçµæã«ãªããã¨ãããã¾ãããã®ãããªåé¡ããã¯ãã®å¯ä½ç¨ã¨è¨ãã¾ãã
サブルーチンかマクロか (P.28)
ã¨ãããã ããå ·ä½çãªä¾ã¯ãªã*4ã
C ã C++ ã®ãã¯ãã«ã¤ãã¦æ°äººã«æããã¨ãããã
- 使ããª
- å¥ã®è¨èªã ã¨æã
- é¢æ°ã¨åãå½åè¦åã«ãããª
- ã¨ã«ãã使ããª
ããªã
C# ã® struct
C# ã® struct ã«ã¤ãã¦ã
ä¸ã®ä¾ã®ããã«ã¡ã³ãã¨ãã¦å¤æ°ã ããããæ§é ãä½ãã¨ã (ãã¨ã§ç¤ºãã¡ã½ããããªããã®ãå®ç¾©ããã¨ã) ã«ã¯ãå®éã«ã¯ã¯ã©ã¹ã§ã¯ãªãæ§é ä½ (struct) ã¨ãã¦å®ç¾©ããã®ã常èã§ãããã®ã»ããããã©ã¼ãã³ã¹ã®ç¹ã§åªãã¦ããããã§ãããã ãããã®å ´åã¯ããã®ãã¨ã§ã¡ã½ããã追å ããã®ã§ãã¯ã©ã¹ã¨ãã¦å®ç¾©ãã¾ããã
クラスの定義と利用 (P.32)
ã¨ãããããããªã«åç´ãªãã®ã§ã¯ãªãã
ã¨ããããããããç´°ããé¨åã¯æ°äººã¯æ°ã«ããå¿
è¦ãªã¯ãã¨è¨ãããæ°ã«ããã¹ãã§ã¯ãªãã¨æãã
å
容ã«ã¤ãã¦ããstruct ã«ããã°ç¡æ¡ä»¶ã§ããã©ã¼ãã³ã¹ãä¸ããããã«æ¸ããã¦ããããèè
ãããä¿¡ãã¦ãããã ãããã©ããããªãã®ã§ã¯ãªãã
ãã£ã¼ã«ãã®ãµã¤ãºã大ããå ´åããæ°ãå¤ãå ´åãé »ç¹ã«ããã¯ã¹åã»ã¢ã³ããã¯ã¹åãçºçããå ´åã¯ãstruct ãã class ã«ããæ¹ãããã
ã¾ããstruct ã«ã¡ã½ãããå®ç¾©ã§ããªããããªè¨è¿°ããããããããééãã
ç¬èªã®ç¨èª
プログラミング言語はどれが良いか?æ±ç¨é«ç´ããã°ã©ãã³ã°è¨èª
æ±ç¨é«ç´ããã°ã©ãã³ã°è¨èªã¯ãåã«ãé«ç´ããã°ã©ãã³ã°è¨èªããããã¯ãé«æ°´æºããã°ã©ãã³ã°è¨èªãã¨å¼ã°ãããã¨ãå¤ãè¨èªã§ããã¨ãã°ãC è¨èªãC++ãC#ãFORTRANãJavaãVisual Basic ãªã©ãããã¾ãã
ç¢æ²¢ããã¨ããæ¥åããã¨ãããèªåã§ç¨èªä½ãã®å¥½ãã§ããã
ãã¡ãªèè
ã®ç¹å¾´ãªã®ãããããªãã
çç¾
C è¨èªã®ç¹å¾´ã¨ãã¦ã
ãªãã¸ã§ã¯ãæåã®è¦ç´ ãã¾ã£ãããªãæç¶ãåã®è¨èªã§ããããã®ããã«ç¿å¾ã容æ
プログラミング言語はどれが良いか? (P.43)
ã¨ãã¦ããã«ãããããã*5ã
プログラミング言語はどれが良いか? (P.48)
å ¨ç¶åå¿è åããããªããä½ããã£ã¦åå¿è åãã¨ããããã£ã¦ã®ã¯é£ããã ãããã©ãç¿å¾ãç°¡åãªãåååå¿è åãã ã¨æããã ãã©ã
ã¤ãã³ãã¨ã¡ãã»ã¼ã¸
ã¤ãã³ãã¨ã¡ãã»ã¼ã¸ã¯ããªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ã§ä½¿ãéè¦ãªæ¦å¿µã§ãã
オブジェクト指向ってようするに何? (P.60)
ã»ã»ã»
ã¦ã£ã³ãã¦ãã¼ã¹ã®ããã°ã©ã ã§ã¯ãçºçããã¤ãã³ãã®ã¡ãã»ã¼ã¸ãå¦çãããã¨ã§ãæä½ãããå¦çãè¡ã£ãããã¾ãããããã¤ãã³ãé§ååããã°ã©ãã³ã° (ã¤ãã³ãããªãã³ããã°ã©ãã³ã°) ã¨è¨ãã¾ãã
ã¤ãã³ãããªãã³ã®ã¡ãã»ã¼ã¸ã¨ãOOP ã®æ¦å¿µã§ããã¡ãã»ã¼ã¸ãæ··åãã¦ãªããï¼
ã¤ãã³ãããªãã³ã§ã®ã¤ãã³ãã¨ã¡ãã»ã¼ã¸ã¯ãOOP ã§ä½¿ãéè¦ãªæ¦å¿µã§ã¯ãªããã*6ï¼
Substring
è¨èªã«ãã£ã¦ãæååã®ã¤ã³ããã¯ã¹ã 0 ããå§ã¾ãã 1 ããå§ã¾ããã¨ãã話ã®ä¸ã§ã
次㫠C# ã®æååæä½ã¡ã½ãããè¦ã¦ã¿ã¾ãããã次㮠C# ããã°ã©ã ã¯ãSubstring(2, 3) ã«ãã£ã¦æååã® 2 æåç®ãã 3 æåãåãåºãã¾ãã
using System; namespace CSCnslApp { class Program { static void Main(string[] args) { String msg = "Hello, Dogs."; Console.WriteLine(msg.Substring(2, 3)); } } }ãã®ããããã®ããã°ã©ã ãå®è¡ããã¨ãellãã¨åºåããã¾ãã
ゼロか 1 か
ã¨ãããããããªãããªããåºåãããã®ã¯ãlloãã ã
ãããªãã¨ãå¹³æ°ã§æ¸ãã¦ãã¾ãã¨ãããã¨ã¯ãä»ã¾ã§æ¬å½ã«åéããã¦ããã®ã ã¨æãã
æ¥åãããããªãã®æ¸ããããã°ã©ã ãå
¨é¨è¦ç´ããã»ããããããããã¾ãããï¼
ãã¼ã¿åã¨åä½
æ¥å¸¸çæ´»ã§æ±ãå¤ã«ããå®ã¯åãããã¾ãããã¨ãã°ãé å±ã§ç¼¶ãã¼ã«ãè²·ãã¨ãã®ãã¨ãèãã¦ã¿ã¾ãããã500ml ã®ç¼¶ãã¼ã«ã 350 åã§è²·ãã¨ãã500 ã¨ããå¤ã¨ 350 ã¨ããå¤ã®æ§è³ªã¯å ¨ãéãã¾ããæã ã¯ãã®ãã¨ãç¹ã«æèãã¦ããããã§ã¯ããã¾ããããæ確ã«åºå¥ãã¦ãã¾ãããã¾ã500 åçãåºãã¦ã350 åã®ç¼¶ãã¼ã«ãè²·ã£ãã¨ãã¾ã (å³ 5.1)ããã®ã¨ãã«ããã¤ãã¨ã㦠150ml ã®æ°´ã渡ãããããããªãã¯é»ã£ã¦åãåãã§ããããï¼
便利で怖いデータ型 (P.114)
人ã¯ãããåä½ã¨ããã
ãã¦ãããä»®ã«ä»å¹´ã®äººå£ããæ¨å¹´ã®äººå£ãå¼ãã人å£åæ ãæ±ããã¤ããã§ãã£ãã次ã®ãããªå¼ãæ¸ãã¦ãã¾ã£ãã¨ãã¾ãããã
int popMovements = popThisYear - area;
ä¸ã®å¼ã¯ãä»å¹´ã®äººå£ããé¢ç©ãå¼ãã¦ããã®ã§æå³ããçµæã¯æ±ãããã¾ãããããã¦ãC# ã§ã¯ãã®ãããªå ´åããå 'double' ã 'int' ã«æé»çã«å¤æã§ãã¾ããããã¨ããã¨ã©ã¼ãå ±åããã¾ãã
ããã®ãããªå ´åãã£ã¦ã®ã¯ãã¡ã§ããããããã« int åã§ä»å¹´ã®ä¸å¸¯æ° familiesThisYear ã§ã追å ãã¦ã¿ã¾ããããï¼ã§ã
int popMovements = popThisYear - familiesThisYear;
ã§ã¯ãã¡ããã¨ã©ã¼ã«ã¯ãªããªãã
C# ã«æ¨æºã§åãã£ã¦ãããã¼ã¿åã¯åä½ãæ±ãã«ã¯åºããããã ããå½ç¶ãªãã ãã©ã
æ£ã®ç¡é大ãè² ã®ç¡é大
ä¸è¬çã«ã¯ãå¤ãã®ããã°ã©ãã³ã°è¨èªã§ãæ°ãã¼ãã§å²ãã¨ä¾å¤ã¨å¼ã¶äºæ ãçºçãã¾ããããããæ¬æ¸å·çæã¾ã§ã®ãã¼ã¸ã§ã³ã® JavaScript ã§ã¯çµæ㯠Infinity ã«ãªãã¾ããInfinity ã¯ãä¾å¤ã¨ããç°å¸¸äºæ ãé¿ããããã®å·¥å¤«ã§ããã¨ã¿ãªããã¨ãã§ãã¾ãã
特殊な値 (P.134)
é©å½ãªãã¨ãè¨ã£ã¦ããããªw
ããã¯ãJavaScript ãä»ã®ã¨ããæ°å¤ãæµ®åå°æ°ç¹æ°ã¨ãã¦æ±ãããã§ãã£ã¦ãä»ã®è¨èªã§ãæµ®åå°æ°ç¹æ°åã使ãã° Inf ã確èªã§ããã
ããã«ãã¦ãããä¾å¤ã¨å¼ã¶äºæ
ãçºçãã¾ããã£ã¦å¤§ä»°ã«è¨ã£ã¦ããã©ãããéã«åããã«ãããªãï¼ãä¾å¤ãçºçãã¾ããã§ããã¨æãã
null
特殊な値 (P.135)
- C/C++ ã§ã¯ null ã¯å¤ã¼ãã¨åãã§ããã¾ããC/C++ ã§ã¯å¤§æåã® NULL ã¯ãå¤ 0ãã¾ãã¯ãæå '\0'ãããã㯠(void *)0 ã表ãã¾ãã
- C# 㨠Java ã§ã¯ãåç §åããªãã¸ã§ã¯ããæãã¦ããªããã¨ã表ãã¾ã (C# 㨠Java ã§ã¯ãnull ã¯ã¼ãã§ã¯ããã¾ãã)ã
- JavaScript ã§ã¯ null ã¯ãå¤ãæã£ã¦ããªãããã¨ã表ãå¤ã§ã (JavaScript ã®å ´åãnull ã¯ã¼ãã§ã¯ããã¾ãã)ã
C ã§ã¯ (void*) 0 㯠NULL ã¨ãã¦ãããããã©ãC++ ã§ã¯ããã¯éæ³ã ãã'\0' 㯠C ã§ããã¡ãªããã*7ï¼
ããã«ãå¤ã¼ãã¨åãã¨ãã表ç¾ãã©ãã ããï¼ãã«ãã¤ã³ã¿ã¯æ´æ°ã® 0 ã¨åãããããã¿ã¼ã³ã§ãªããã°ãªããªãã¨ãããããããªããã
追è¨ï¼
ã³ã¡ã³ãããã ããããã«ã
- C89 ã§ã¯ NULL 㯠0 ã ( (void*)0) ã¨ãã¹ã(å ¨ä½ãæ¬å¼§ã§å²ãå¿ è¦ã¢ãª)
- '\0' ã¯ãã«ãã¤ã³ã¿ã¨ãã¦æå¹ãªã®ã§ãC99 ã C++ ã®ããã« NULL ãå¦çç³»å®ç¾©ã®å ´åæå¹
- ãnull ã¯å¤ã¼ãã¨åããã¨ãã表ç¾ã«ééãã¯ãªããã
Nothingãthisãvoid
Infinity ã null ã¨åãã¨ããã§ãNothing ã thisãvoid ã¨ãã£ããã®ã«ã¤ãã¦ã説æããããã©ãåºæ¬ããããã¯å¤ã§ã¯ãªãã
ããè¯ãã³ã¼ãï¼ãããã
ã°ãã¼ãã«å¤æ°ã使ç¨ãã¦ããã³ã¼ãããã¼ã«ã«å¤æ°ã使ç¨ããæ¹æ³ã«æ¹è¯ãã¦ãããã«æçµçã«ã¯ãããè¯ãã³ã¼ããã¨ãã¦ã²ã©ãã³ã¼ããç´¹ä»ãã¦ããã
ã°ãã¼ãã«å¤æ°ããã¼ã«ã«å¤æ°ã«ç½®ãæããããã°ã©ã ã¯ãããªãè¯ããªãã¾ããããç¾å¨ã®ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ã®æè¡ã容æã«å©ç¨ã§ããç°å¢ã§ã¯ãå¿ ãããåªããã³ã¼ãã¨ã¯è¨ãã¾ãããé·æ¹å½¢ãæ±ããã®ããã°ã©ã ããä»å¾ã©ãã©ãæ¡å¼µãã¦ããã¤ãããªãããã¨ãã°æ¬¡ã®ãããªã³ã¼ããæ¸ããã¨ãèãã¾ãããã
// // Rrectangle.cpp // #include <iostream> #include <cmath> using namespace std; class Rectangle { private: int x1, y1, x2, y2; public: Rectangle() {} Rectangle(Rectangle *rect) { x1 = rect->x1; y1 = rect->y1; } Rectangle(int x, int y) { x1 = x; y1 = y; } void getTopLeft() { cout << "å·¦ä¸ã®X座æ¨>"; cin >> x1; cout << "å·¦ä¸ã®Y座æ¨>"; cin >> y1; } void getBottomRight() { cout << "å³ä¸ã®X座æ¨>"; cin >> x2; cout << "å³ä¸ã®Y座æ¨>"; cin >> y2; } double getArea() { return abs(x1-x2) * abs(y1-y2); } double getDiaglen() { return sqrt( (double) ((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2)) ); } void printRectInfo() { cout << "(" << x1 << "," << y1 << ")-(" << x2 << "," << y2 << ")ã®é·æ¹å½¢" << endl; } void printArea() { cout << "é¢ç©ï¼" << getArea() << endl; } void printDiaglen() { cout << "対è§ç·ã®é·ãï¼" << getDiaglen() << endl; } }; int main() { // ãã¼ã«ã«å¤æ° Rectangle *rect1 = new Rectangle(); rect1->getTopLeft(); rect1->getBottomRight(); rect1->printRectInfo(); rect1->printArea(); rect1->printDiaglen(); cout << "æ°ããé·æ¹å½¢" << endl; Rectangle *rect2 = new Rectangle( rect1 ); rect2->getBottomRight(); rect2->printRectInfo(); rect2->printArea(); rect2->printDiaglen(); return 0; }グローバル変数とクラス変数/ローカル変数 (P.146)
çªã£è¾¼ã¿ã©ããã¨ãã¦ã¯ã
- (å ¨ä½çã«) ãªã«ãã® Java (ããã㯠C#) ãã©ã
- Rrectangle.cpp ãªãã¦ãå¤ãªååã¤ãããã§ãã
- ãããã¨å®è£ ãã¡ã¤ã«ã«åé¢ããªãã®ï¼
- Pimpl ã¤ãã£ãªã 使ããªãã®ï¼
- ãªãã§ã³ãã¼ã³ã³ã¹ãã©ã¯ã¿ãããªãã®ï¼
- ãªãã§åæåãªã¹ã使ããªãã®ï¼
- ãªã㧠explicit ãªãï¼ Rectangle rect3 = rect1; ã¨ãããããã¢ã¤ãã§ããã©
- Rectangle(Rectangle*) ã§ãªãã§å ¨é¨ã³ãã¼ããªãã®ï¼
- ãªãã§æ»ãå¤åã void ãªã®ã« get ãªãã¦ååã¤ããã®ï¼
- ãªãã§ã¡ã³ãé¢æ°ã§ cin ã¨ã cout 使ã£ã¦ã¡ã³ãå¤æ°è¨å®ãã¦ãã®ï¼
- ãªã㧠abs ã« int 渡ãã¦ãã®ï¼
- ãªã㧠C++ å½¢å¼ã®ãã£ã¹ãæ¼ç®åã使ããªãã®ï¼
- ãªãã§åºåã« operator<< ã使ããªãã®ï¼
- ãªã㧠printArea ãã printDiaglen ãããå¤é¨ã«åºãããã®ãã¡ã³ãé¢æ°ã«ãã¦ãã®ï¼
- // ãã¼ã«ã«å¤æ° ã£ã¦ã³ã¡ã³ãã«ãã©ããªæå³ãããã®ï¼
- delete ãå¿ãã¦ãã»ã»ã»ãªã㧠auto_ptr 使ããªãã®ï¼ããããããã new ããå¿ è¦ãªããã
ãé·æ¹å½¢ãæ±ããã®ããã°ã©ã ããä»å¾ã©ãã©ãæ¡å¼µãã¦ããã¤ãããªãããã¨ãã°æ¬¡ã®ãããªã³ã¼ããæ¸ããã¨ãèãã¾ãããããã ã£ã¦ï¼
åè«ã¯ããã¦ããã
å¼ã¨æ
ãarea = PI * r * r;ãã®ãããªãã®ã¯ãå¼ã§ããã¨åæã«ãä»£å ¥ãè¡ãã®ã§ããããã¹ãã¼ãã¡ã³ãã§ãã
ã»ã»ã»
ãã¨ãã°ã次ã®å¼ã¯ãã¾ãã1 ã« 3 ãå ããå¤ 4 ã決å®ãã¾ãã次ã«ããã®å¤ã x ã«ä»£å ¥ã㦠x ã®å¤ã決å®ãã¾ããx = 1 + 3;プログラムの要素 (P.151)
ãã£ã¨ããã®äººãã¤ã³ã¿ããªã¿ã®æ¬ãåºãã¦ã¾ããããã
å¼ã¨æã®éããåãããªãã¨ããã¡ãã£ã¨è´å½çãªæãããããã§ããã©ããããã代å
¥ãè¡ãããæï¼ãªã a = b = c ã¨ãã©ã説æãããã ã
ãã¦ãããã§æ¬¡ã®ãããªå¼ããããã®ã¨ãã¾ãã
x = 3 + 5 * 7;プログラムの要素 (P.152)
ã ãããããã¯æ*8ã
åªå é ä½ã¨æ¬å¼§
x = 3 + 5 * 7;ãããå®è¡ãããã¨ãçµæ㯠3 + (5 * 7)=3+35=38 ã¨ãªãã¾ããããã¯ãä¹ç® (*) æ¼ç®åã®åªå é ä½ããå ç® (+) æ¼ç®åã®åªå é ä½ãããé«ããã¨ãããã¨ãç¥ã£ã¦ããã°ç°¡åã«ç解ã§ãã¾ããããããã®åªå é ä½ãå¤æ´ãã¦å ã« 3+5 ãå®è¡ãããã¨ãã«ã¯ãx = (3 + 5) * 7;ãã«ãã¾ãã() ã®åªå é ä½ã¯ (ã»ã¨ãã©å¸¸ã«) æãé«ãããã§ãã
プログラムの要素 (P.152)
æ¼ç®åã®åªå é ä½ã¨ãããã¨ãèãããã¨ãããã°ãããã¾ã§ã¯ããã§ãããã
è¯ããªããï¼åªå
é ä½ãå¼·å¶ããããã®æ¬å¼§ã¯æ¼ç®åãããªããï¼
ã¤ãªãããã¿ã㨠C ã JavaScript ã®è©±ã ã¨æã£ã¦ãããã¦ãã¨ã¯ãé¢æ°å¼ã³åºãã® () æ¼ç®åãåªå
é ä½å¤æ´ã®æ¼ç®åã§ããã¨åéããããã§ããããã
ç´°ãããã¨ã ãã©ããå
ã« 3+5 ãå®è¡ãã£ã¦ã®ãã¡ãã£ã¨å¼ã£ãããããå
ã« 3+5 ãè©ä¾¡ããããï¼ã©ãã§ããããã
ã»ã»ã»æ¬å½ã«ãã®äººãã¤ã³ã¿ããªã¿ã®æ¬æ¸ããã®ï¼
追è¨ï¼
ã³ã¡ã³ãããã ããããã«ãC è¨èªã C++ ã§ã¯ () ã¯åé
æ¼ç®åãããã
Java ã JavaScript ã¨ã¯éãã®ãã»ã»ã»
æ´ã«è¿½è¨ï¼
ã³ã¡ã³ãããã ããããã«ããã£ã±ãC è¨èªã C++ ã§ã () ã¯æ¼ç®åãããªããããã
ãã¨ã§ç¢ºèªãã¦ã¿ãã確認したããã£ã±ãæ¼ç®åãããªãã
SQL
åãåãã (ãã¼ã¿ã®æ¤ç´¢ãåå¾) ã« SQL (Structured Query Languageãæ§é ååãåããè¨èª) ãå©ç¨ãããã¼ã¿ãã¼ã¹ããã使ããã¾ãã
データの保存 (P.169)
SQL は何かの略じゃないãã ã£ã¦ã°ã
ããã BLOB (Binary Large OBjectããã¤ããªã©ã¼ã¸ãªãã¸ã§ã¯ã) ã¨è¨ãã¾ãã
データの保存 (P.170)
æé©å
ããã°ã©ã ã¯ä½¿ããéãã®æé©åæè¡ã使ã£ã¦ã§ããã ãé«éåããã¹ãã§ãã
見かけの速さの重要性 (P.187)
å
¨ã¦ãã¢ã»ã³ããªã§æ¸ãã¨ãããã¨ã§ããããããã¾ãã
æé©åã®è©±ã¯æ°äººã«ãã¹ããªã®ãã©ãããã¨ããã®ã¯ç½®ãã¨ããã¨ãã¦ããæé©åã®ããæ¹*9ãè¼ã£ã¦ããªãã¨ã¯ã©ããããã¨ã ã
ã§ãæé©åã®ææ³ã¨ãã¦ã
- é¢æ°ã®ãã¯ãã«ããç½®æ
- å¥ã¢ã¸ã¥ã¼ã«ã«ãã¦å®è¡æãã§ãã¯ãã¯ããã¦ã³ã³ãã¤ã«
- SSE ã SSE2 ã®ä½¿ç¨
- æ´æ°ã«å¤æãã¦è¨ç®å¾ãåå¤æ
- 並åå¦ç
- ã¢ã©ã¤ã³ã¡ã³ãã®èª¿æ´
ãæããå¾ã«ã
ã¹ã¯ãªããè¨èªããã¯ãè¨èªãªã©ã§ã¯ãé«éåã®æ¹æ³ã¯éå®ããã¾ããã§ãããã¨ã¯ãå°ãããµã¤ãºã®å¤æ°ã使ãã¨ããã¢ã«ã´ãªãºã ãæ¹è¯ããç¨åº¦ã§ãã
細かいことにこだわろう (P.192)
ã£ã¦ãã¢ã«ã´ãªãºã ã®æ¹è¯ã¯çã£å
ã«èæ
®ãã¹ããã®ã ãw
ä½ãã®ãã¢ã«ã´ãªãºã ãå¤ããã£ã¦ãããªã«ããã©ã¼ãã³ã¹åä¸ããªãããã¿ãããªãã¥ã¢ã³ã¹ã
ããããããã¦ã¼ã¶ã¼ã®ãã·ã³ã¯é
ã(P.185)ãã®ã«ããç¾å¨ã®ã³ã³ãã¥ã¼ã¿ã«ã¯ãå¤ãã®å ´åããã«ãã³ã¢ã® CPU ãæè¼ããã¦ãã¾ã(P.191)ãã£ã¦ãé½åãããªã並åå¦çè¨ãããã£ãã ãã¡ããããã¨ã
ããã¯ãããã°ã¨ã¯è¨ããªã
æãè¯ããããã°ã®æ¹æ³ã¯ããããã°ããªãã§æ¸ãããã°ã©ã ãè¨è¨ãã¦ä½ããã¨ã§ããçç¾ãã¦ããããã«æããããããã¾ãããããããççã§ãã
デバッグの技法 (P.194)
çç¾ãã¦ããããã«æããããããªãã¦ãçç¾ãã¦ããã ãã
ãããã°ã¨ã¯ãããã°ãåãé¤ããã¨ãã ãããã¯ãããããã°ããªããã°ããã㯠(ã©ãï¼) ãããã°ã¨ã¯è¨ããªãã
ããã°ãä½ããªãããã«ã¯ãã³ã¼ããæ¸ããªããã¨ã ãããé£æ³ãããã ã¨ã¯æããã©ããã£ã¡ã¯çç¾ãã¦ãªãã
ä¾å¤ãªãã¸ã§ã¯ã
ä¾å¤ãå¦çããã¨ãä¾å¤ãªãã¸ã§ã¯ãã¯æ¶æ» ãããã®ã¨ã¿ãªããã¾ãã
エラーリカバリーの重要性 (P.198)
ä¾å¤ãªãã¸ã§ã¯ãã¯å¦çããããã¨è¨ã£ã¦æ¶æ»
ãããããããªãã§ããã
GC ã®ããè¨èªãªããGC ã«ååãããã¾ã§ã¡ã¢ãªä¸ã«åå¨ãç¶ããããC++ ã§ãå¤ã§æãã¦åç
§ã§åãåããã£ã¦ã®ã¯ catch ãæããããã£ã¦ä¾å¤ãªãã¸ã§ã¯ããæ¶æ»
ãããããããªããã¨ãããã¦ããã ãã
ãããããä¾å¤ãå¦çããããªãã¦ãã£ã¦ããã©ãåã¹ãã¼ã¯ã©ã説æãããã ãããã
ç¡çã«ç¬èªã®è§£èª¬ããããã¨ãã¦å¤±æãã¦ããä¾ãªãã ãããªã
æ§æï¼
C# ã®å ´åã®ä¾å¤å¦çã®ã³ã¼ãã¯ãåºæ¬çã«ã¯ãtry 㨠catch ã使ã£ã次ã®ãããªæ§æã§ãã
// ä¾å¤å¦çã®ä¾ try { ( ä¾å¤ãçºçããå¯è½æ§ã®ããã³ã¼ã ) } catch (ä¾å¤ã¯ã©ã¹ e) { ( ä¾å¤ã¯ã©ã¹ã®ä¾å¤ãçºçããã¨ãã«å®è¡ããã³ã¼ã ) }エラーリカバリーの重要性 (P.198-199)
ããã¯æ§æã¨ã¯è¨ããªãããããªãï¼åºæ¬çãããªãå ´åã«ã¯ãªã«ãå¥ã®æ§æã§ãç¨æããã¦ãã®ï¼
ã¤ã³ã¿ããªã¿ã®æ¬æ¸ãã¦ã人ãªãã ããããç¨èªããããã¡ãã¨ä½¿ãããã
ä¾å¤ã¯ã©ã¹ã®ä¾å¤ã£ã¦æå³ãåããã«ãããã
ã¡ãªã¿ã« Java ã ã¨ä¾å¤å¦çã®æ§æã¯ã
TryStatement: try Block Catches try Block Catchesopt Finally
以ä¸ç¥ã® try æã使ç¨ãããC# ã®è¨èªä»æ§ã¯ç¥ããªããã ãã©ãä¼¼ããããªãããããªãã®ï¼
VC++ ãã使ã£ã¦ãªããããªã®ã«ããããªãã¨ãããè¨ãã
ã³ã³ãã¤ã©ã«ãã£ã¦ã¯ãäºå®ä¸ãç¡æå³ãªè¦åãå ±åãããã®ãããã¾ãããã¨ãã°ãMicrosoft ã® Visual C++ ã§ã¯ãstrcpy() ã strcat() ã®ãããªæ¨æºçãªæååé¢æ°ã C/C++ ã®ã½ã¼ã¹ã³ã¼ãã®ä¸ã§ä½¿ãã¨è¦åãåºã¾ããMicrosoft ã¯ãã»ãã¥ãªãã£ä¸ã®çç±ã§ strcpy() ã®ä»£ããã« strcpy_s() ã使ããstrcat() ã®ä»£ããã« strcat_s() ã使ããã¨ãæ¨å¥¨ãã¦ãã¾ããããããç¾æç¹ã§ããã®ãããªéæ¨æºã®è¦åã¯ç¾å¨ãå°æ¥ã Microsoft ã®éçºãã¼ã«ã ãã«é ¼ã£ã¦ããéçºè ã«ã¯æå³ãããå¯è½æ§ãããã¾ãããä¸è¬çã«ã¯ç¡æå³ãªè¦åã§ããç¡æå³ãªè¦åã¯ç¡è¦ããã»ããããã§ããããã»ã»ã»ä»¥ä¸èªé
警告されたらどうするか (P.206)
ãããªãã¨ãæ°äººã«æããã®ãï¼æ¬æ°ã§ããã¦ãããããããã¨ããããã¯ãã®åºçªã§ããããã
C++ ãªã _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES ã ON ã«ããã ã¨ãããããã C ã®æååé¢æ°ã使ããã« std::basic_string 使ãã ã¨ããããããã¯ä»ã«ãããã ãããã
ã¨ãããã§ãããããªãã®æ¸ãããã°ã©ã ããªãã VC++ 以å¤ã§ã¯ã³ã³ãã¤ã«ãããã¨ãªãããã«è¦ãããã§ããã
ééã£ã¦ããã¨ã¯è¨ãåããªããã®
èè ã®èã
ãããªãã¨ãè¨ã£ã¦ãã¾ã£ã¦ã¯èº«ãèããªãã®ã ããã©ã»ã»ã»æ£ç´ãèè
ã®èããæ°ã«é£ããªãã
ã»ã»ã»ããã§çµãã£ã¦ãã¾ã£ã¦ã¯æ¬å½ã«èº«ãèããªãã®ã§ãã¡ãã£ã¨æãä¸ããã
ã¾ããæåã¨æå¾ã§è¨ã£ã¦ããã¨ãå¤ãã£ã¦ããæã
æ¬æ¸ã®å 容ã¯ãååçã«ããã°ã©ãã³ã°è¨èªã®ç¨®é¡ã«ã¯é¢ä¿ããã¾ãããåºæ¬çã«ã¯ããããã種é¡ã®ããã°ã©ãã³ã°è¨èªã®ããã°ã©ã ã«å ±éãããã¨ãåãä¸ãã¾ãããã ããç¹ã«ç¹å®ã®ç¨®é¡ã®ããã°ã©ãã³ã°è¨èªã«å½ã¦ã¯ã¾ããã¨ãããå ´åã¯ããã®ãã¨ã示ãã¦è§£èª¬ãã¾ã
はじめに (P.3)
æ¬æ¸ã§ã¯ãã¾ãã¾ãªããã°ã©ãã³ã°è¨èªãããã°ã©ãã³ã°ç°å¢ãåãä¸ãã¦ãã¾ãããè¨èªãç°å¢ã«ãã£ã¦æ£å対ã®ãã¨ãããã«ããããããããã¾ãã¾ãªãããã¯ã大èä¸æµã«åãä¸ããã®ã«ã¯ããã¡ããçç±ãæ ¹æ ãããã¾ãã
一般的で原則的な話 (P.223-225)
ã»ã»ã»
æ¬æ¸ãèªãã§ãã¦ããããã¯ééã£ã¦ããããããªãã ãããï¼ãã¨æã£ã人ãããããããã¾ããã
å®éã«ãæ¬æ¸ã®è¨è¿°ã®ä¸ã«ã¯ç¹å®ã®ç°å¢ãç¹å®ã®ããã°ã©ãã³ã°è¨èªã«ã¯ãã¦ã¯ã¾ããªããã¨ãè¨ãæããã°ç°å¢ãããã°ã©ãã³ã°è¨èªã«ãã£ã¦ã¯ééãã§ãããã¨ã (å°ãã¯) ããã¾ãã
ã»ã»ã»
ãããããããã¨ãæ¬æ¸ã®ã»ã¨ãã©ã®æ®µè½ã§ãä¸è¬çã«ã¯ãããååã¨ãã¦ãããããã¯ããå¤ãã®å ´åã«ã¯ãã¨ããä¸è¬ã«è¯ã使ããã¦ããéçºç°å¢ã§ã¯ããªã©ã使ããã¨ã«ãªããã»ã»ã»ããã§ãæ¬æ¸ã§ã¯ãã¡ãã¡ãä¸è¬çã«ã¯ãããååã¨ãã¦ãã¨æã£ã¦ãã¾ããã
ã»ã»ã»
èªåã®å¸¸èã¯ä¸éã®å¸¸èã¨ã¯å¿ ãããä¸è´ããªãã¨ãããä¸éä¸è¬ã§ãå½ããåã§ãããªããå¿ããããã¡ãªãã¨ã常ã«å¿ããªãããã«ããå¿ è¦ãããã¾ã
ã»ã»ã»
ããã°ã©ãã³ã°ãç¿å¾ãã¦ããç¨åº¦çµé¨ãç©ãã¨ããã¡ãã¡æ¤è¨¼ããã«ãããã¾ã§ã®èªåã®çµé¨ã¨ç¥èã§å¤æããããã«ãªãã¾ããããã®ãããªã¨ãã«ç¬æãåè¦ãæã¡è¾¼ã¾ãªãããã«å¸¸ã«æ°ãã¤ããå¿ è¦ãããã¾ã (èè èªæ)ã
ãã¯ããã«ãã§ã¯ããããã種é¡ã®ããã°ã©ãã³ã°è¨èªã«å
±éãããã¨ãåãä¸ãããã¨ãããç¹å®ã®ç¨®é¡ã®ããã°ã©ãã³ã°è¨èªã«å½ã¦ã¯ã¾ãå ´åã¯ãã®ãã¨ã示ããã¨ãè¨ã£ã¦ããã®ã«ãä¸çªæå¾ã§ã¯ãæ¬æ¸ã®è¨è¿°ã®ä¸ã«ã¯ç¹å®ã®ç°å¢ãç¹å®ã®ããã°ã©ãã³ã°è¨èªã«ã¯ãã¦ã¯ã¾ããªããã¨ããããã¨ãã¦ããã
æ£ç´ãé½åãè¯ãããã223 ãã¼ã¸ä»¥éã¯ãä½ãææããã£ãéã®ãéããã«ãè¦ããã
ã¤ããæ¤è¨¼ãããw
ããã¦ãããä¸ç¹ã
ã²ã¨ã¤ã®ããã°ã©ãã³ã°è¨èªããã¹ã¿ã¼ããã°ãä»ã®ããã°ã©ãã³ã°è¨èªãç¿å¾ããã®ã¯å®¹æã§ããããã°ã©ãã³ã°ã§ä½¿ãããæ¦å¿µã¯ããã°ã©ãã³ã°è¨èªã®ç¨®é¡ã«é¢ä¿ãªãã»ã¨ãã©åããªã®ã§ãä»ã®ããã°ã©ãã³ã°è¨èªããã¹ã¿ã¼ããã¨ãã«ã¯ãèªåãæ¢ã«ç¿å¾ããè¨èªã¨ãããããç¿å¾ãããã¨ãã¦ããè¨èªã®éãã«ç¦ç¹ãå½ã¦ã¦å¦ç¿ããã¨ãæ°ããè¨èªãæ¯è¼ç容æã«ç¿å¾ãããã¨ãã§ãã¾ãã
プログラミング言語はどれが良いか?
ä½åãè¨ã£ã¦ããã©ãã²ã¨ã¤ã®è¨èªãåºæ¥ãããã£ã¦ãä»ã®è¨èªã®ç解ã容æã«ãªãã¨ã¯æããªã*10ã
å®éã«ãC++ ã Java ã C# ã®ããã«ä½¿ã£ã人ããã¾ãããã*11ã
ããã«ãããã°ã©ãã³ã°ã§ä½¿ãããæ¦å¿µã£ã¦ä½ã®ãã¨ãè¨ã£ã¦ãããã ãããã
ããã«ããã«ãã©ã®è¾ºã®ã¬ãã«ã«éãããããã¹ã¿ã¼ãããã¨ããç¿å¾ãããã¨ãè¨ãããã ãããã
æªã ã«ã©ã®è¨èªãè¸ãå¼µã£ã¦ããã¹ã¿ã¼ããããªãã¦è¨ããªããã ããã©ãã
æ§é åã¸ã®ã¢ããã¼ãï¼
ãã¨ãã°ãJava ã®ãããªè¨èªã§ãåæ©ã®å¦ç¿æ®µéã§ã¯ã²ã¨ã¤ã®ã¯ã©ã¹ã®ã²ã¨ã¤ã® main() ã«ããã°ã©ã ã³ã¼ãå ¨ä½ãè¨è¿°ãããã¨ãããããã¾ãã
ã»ã»ã»
ã¾ããmain() ã®ä¸ã®ããã°ã©ã ã³ã¼ããã³ã³ã¹ãã©ã¯ã¿ã«å ¥ãããã¨ãæ¤è¨ããã¹ãã§ãã
ããã¨ã次ã®ãããªããã°ã©ã ã«ãªãã¾ããpublic class javaarray { // é åã®å 容ãåºåããã¡ã½ãã void printArray(int a[]) { for (int i=0; i<a.length; i++) System.out.print(a[i] + " "); System.out.println(); } // ã³ã³ã¹ãã©ã¯ã¿ javaarray() { // é åã宣è¨ãã int data[] = new int[10]; // é åãåæåãã for (int i=0; i<data.length; i++) data[i] = i + 1; // é åã®å 容ãåºåãã printArray(data); // é åã®å 容ãå¤æ´ãã data[1] = 11; data[5] = 55; // å¤æ´ããé åã®å 容ãåºåãã printArray(data); } public static void main(String[] args) { javaarray ja = new javaarray(); } }main() ã®ä¸ã®ããã°ã©ã ã³ã¼ããã³ã³ã¹ãã©ã¯ã¿ã«å ¥ããjavaarray ã¯ã©ã¹ã®ãªãã¸ã§ã¯ããçæãã¦å®è¡ãããã¨ã«ãã£ã¦ãstatic å¤æ° (éçå¤æ°) ãªã©ã使ããªãã§æ¸ãããã«ãªãã¾ãã
構造化へのアプローチ (P.20-21)
ã»ã»ã»ç«æ´¾ãª Java ããã°ã©ã ã§ããã
çªã£è¾¼ã¿ã©ããã¨ãã¦ã¯
- ãªãã§ã¯ã©ã¹åã JavaArray ãããªããã
- Arrays.toString 使ã
- main ã®å¼æ°ã§ã¯ String[] args ãªã®ã«ãã®ã»ãã®é¨åã§ã¯ãªã㧠å å¤æ°å[] å½¢å¼ï¼
- main ã«å ¨é¨çªã£è¾¼ãã®ã¯ãã¡ã®å ¸åä¾ã ãã©ãã³ã³ã¹ãã©ã¯ã¿ã«å ¨é¨çªã£è¾¼ãã®ããã¡ã®å ¸åä¾
- static å¤æ°ãªã©ã使ããªãã§æ¸ãã®æå³ä¸æ
ãªãã¨ããããC 㨠Java ã足ã㦠2 ã§å²ã£ããããªæãã
å ¥ãåé¢æ°ã¨å¿åé¢æ°ã§ã¯ãå¿åé¢æ°ã®æ¹ãé©åãªå ´åãããï¼
ããã°ã©ãã³ã°è¨èªã«ãã£ã¦ã¯ãé¢æ°ã®ä¸ã«é¢æ°ãå ¥ãåç¶æ ã§å®ç¾©ã§ãããã®ãããã¾ãããã¨ãã° JavaScript ã§ã¯ã次ã®ããã«é¢æ°ã®ä¸ã«é¢æ°ãè¨è¿°ãããã¨ãã§ãã¾ãã
function distance(x1, y1, x2, y2) { function square(x) { return x*x } var dx = x2 - x1; var dy = y2 - y1; return Math.sqrt(square(dx) + square(dy)); }ã»ã»ã»
ããã°ã©ãã³ã°è¨èªã«ãã£ã¦ã¯ãå¿åé¢æ°ã¨ããååã®ãªãé¢æ°ã使ç¨ã§ããå ´åãããã¾ãã次ã®ä¾ã¯ JavaScript ã® Function ã³ã³ã¹ãã©ã¯ã¿ã¨ãããã®ã使ããå¿åé¢æ°ãå®ç¾©ã㦠f ã¨ããååã®å¤æ°ã«ä¿åãã¦å©ç¨ããä¾ã§ããfunction distance(x1, y1, x2, y2) { var f = Function("x", "return x*x"); var dx = x2 - x1; var dy = y2 - y1; return Math.sqrt(f(dx) + f(dy)); }ã»ã»ã»
入れ子関数と匿名関数 (P.22-23)
ããã°ã©ã ã®æ§é åã¨ãã観ç¹ããã¯ãå ¥ãåã®é¢æ°ãããå¿åé¢æ°ã®ã»ããé©åã§ããå ´åãããã¾ãã
ã»ã»ã»ãªãã§ï¼
function ãªãã©ã«ä½¿ãã°å
¥ãåé¢æ°ãå¿åé¢æ°ããéããªãã¦åãããªãæããªã®ã«ã
ãããããããã°ã©ã ã®æ§é åã¨ãã観ç¹ã£ã¦ä½ï¼
ã¯ã©ã¹ã®è¨è¨ã®çè«ã£ã¦ãªã«ï¼
ã¯ã©ã¹ã®è¨è¨ã¯çè«çã«ã¯åç´ã§ã
クラスの定義と利用 (P.37)
ãã®çè«ãkwsk
ã¾ãããåè©æ½åºæ³ãããªããã^^;
å®å ¨ãªãªãã¸ã§ã¯ãæåè¨èª
C# ã®ç¹å¾´ã¯ããªãã¨ãã£ã¦ãå®å ¨ãªãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°è¨èªã§ããã¨ããç¹ã§ãããããã¨ãã°ãC# ã§ã¯çµã¿è¾¼ã¿ãã¼ã¿åã§ãããã¹ã¦ãªãã¸ã§ã¯ãã§ã (C# ã®ãã¼ã¿åã¯ã.NET Framework ã¨ãããªãã¸ã§ã¯ãæåã®æ®ããã©ã¤ãã©ãªã®æ§é ä½ã¨å¼ã¶ãã®ã®ã¨ã¤ãªã¢ã¹ (å¥å) ã§ã)ãã¾ãããªãã¸ã§ã¯ãæåããã°ã©ãã³ã°è¨èªã¨ãã¦ã¼ãããè¨è¨ãããããã«ããªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ã¨ãã¦ä¸è²«ãã¦ãã¾ãã
プログラミング言語はどれが良いか? (P.45)
class 㨠structt ãåãã¦ããæç¹ã§å®å
¨ã¨ã¯è¨ããªããããªã»ã»ã»ï¼
ã¸ã§ããªã¯ã¹ããªãã¸ã§ã¯ãæåã®è¦ç´ ãããªãããã©ã ãå¼ããªãã¸ã§ã¯ãæåã®è¦ç´ ãããªããã»ã»ã»
ããã¦ããã°ã©ã ã
// // hello.cs // using System; namespace CSCnslApp { class Program { static void Main(string[] args) { String msg = "Hello, C#"; Console.WriteLine(msg); } } }プログラミング言語はどれが良いか? (P.45)
ããã°ã©ã ã®ä¸ã§ãstring 㨠String ã使ã£ã¦ããã®ã¯ä½ãæ·±ãçç±ã§ãããã®ã ãããï¼
åå
ã¢ã³ãã¼ã¹ã³ã¢ã«ã¤ãã¦ã
ç¹ã«çç±ããªããã°ãååã®å é ã«ã¢ã³ãã¼ã¹ã³ã¢ã使ãã®ã¯é¿ããã»ããããã§ããããã³ã³ãã¤ã«æã«ååã®å é ã« 1 åã¾ãã¯è¤æ°åã®ã¢ã³ãã¼ã¹ã³ã¢ãèªåçã«ä»ããã³ã³ãã¤ã©ãããããããã§ãã
名前の付け方 (P.69)
ãã¼ã£ã¨ï¼å¦çç³»ã«äºç´ããã¦ãã¨ãããããããã¨ãè¨ã£ã¦ãã®ããªï¼
ããã«ããã£ã¦ç¹å®ã®è¨èªã®è©±ãªãã ããããã¯ããã«ãã«å¾ããªãããã示ãã¦ããã¹ãã
for (int i=0, x=0; i < n; i++) x += 1; // x = x + 1 ã¨åã名前の付け方 (P.69)
ä½ãã®ç¡æå³ãªããã°ã©ã w
ãã®å¾ã« i, j, k, ... ã®ç±æ¥ã¨ã㦠FORTRAN ã®æé»ã®å宣è¨ãåãä¸ãã¦ãããã©ã確ãä»ã«ã説ã¯ãã£ãã¯ããããã ããåãä¸ããã®ã¯ããããªãã®ãã¨ã
ããã«ããã§ã¯ã
ãªããè¤æ°ã®åã種é¡ã®ååãåºå¥ããããã«ãã¢ã«ãã¡ãããã®ååã®ãã¨ã«æ°åãã¤ãªãããã¨ãããããã¾ãããã¨ãã°ãè¤æ°ã®æå (Character) ãæ±ãããã°ã©ã ã§ã¯ãc0ãc1ãc2ããããã¯ãch1ãch2ãch3 ã®ããã«ãã¦ããããã®æåãåºå¥ãã¾ããã¾ããè¤æ°ã®é·æ¹å½¢ (Rectangle) ã®ãªãã¸ã§ã¯ããæ±ãããã°ã©ã ã§ã¯ãrect1ãrect2ãrect3 ã®ããã«ãã¦ããããã®ãªãã¸ã§ã¯ããåºå¥ãã¾ãã
名前の付け方 (P.71)
ã»ã»ã»æ¢ãã¦ã
ãµã³ãã«ã§ã¯ããããæ°å使ããããªããããªå ´åããããã©ãæ®éã®ããã°ã©ã ã ã£ããä½ãããé©åãªååãããã¯ãããããé
åã¨ãã³ã¬ã¯ã·ã§ã³ã«ããã®ãæ£ãããã
ãã®äººããµã³ãã«ããå¼ã£ããã¨ãªãããããªãã®ï¼ããã常èã ã¨æã£ãã大ééãã§ããã
è¨èªãé¸ã°ãªãã©ã¤ãã©ãªã§ãä½ãæ°ã§ããï¼
名前の付け方 (P.71)
- ä¸è¬ã«ãå¤æ°åã®å é ã¯å°æåã«ãã¾ãã
- é¢æ°ãã¡ã½ããã®ååã§ã¯ã[åè©] + [åè©] ã®å½¢å¼ã«ãããã¨ãããããã®å ´åãåè©ã®å é ã¯å°æåã«ãã¦ãåè©ã®å é ã¯å¤§æåã«ãã¾ãããã¨ãã°ãgetValue() ã¨ããsetName() ã®ãããªååã使ããã¾ãã
- ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ã§ã¯ãã¯ã©ã¹åã®å é ã¯å¤§æåã«ãã¦ããªãã¸ã§ã¯ãåã®å é ã¯å°æåã«ãã¾ãã
- ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ã§ã¯ãã¤ã³ã¿ãã§ã¼ã¹ã®ååã®å é æåã大æåã® I ã«ãã¾ãã
ã¨ãããã©ãå¤æ°ã«ã¤ãã¦ã¯ Prolog ã¯å¤§æåããå§ã¾ãããã¡ã½ããå㯠.NET ç³»ã®è¨èªã¯å¤§æåããå§ã¾ãããã¯ã©ã¹å㯠C++ ã®æ¨æºã©ã¤ãã©ãªã¯å°æåããå§ã¾ãããã¤ã³ã¿ã¼ãã§ã¤ã¹å㯠Java ã®æ¨æºã©ã¤ãã©ãªã¯ I ããå§ã¾ããªãã
使ããæåãè¨èªã«ãã£ã¦ã¾ã¡ã¾ã¡ã§ãããã«ãã£ã¦ä¾ãã° Ruby ã¨ã Scheme ã§ã¯ çå½å¤ãè¿ãã¡ã½ãã㯠? ã§çµãããã©ãä»ã®è¨èªã¯ isXxx ã®ãããªå½¢å¼ã使ããªã©ãªã©ã
ã¨ãããã¨ã§ãååã®ä»ãæ¹ã«ã¤ãã¦ã¯è¨èªãè¶
è¶ãã¦è¨ãããã¨ã¯ããåãããããååãä»ããããã¨ããããªããããªãããªãããã§ãå¤æ°åã®é·ããå¶éããã¦ãè¨èªã ã¨ããããè¨ããªãã®ãã
ãããããããä¸ã§ã¯ã¯ã©ã¹åã®å é ã大æåã«ããã¨ãã£ã¦ãããªããããã®æ¬ã® Java ã®ã¯ã©ã¹åã¯ãã¨ãã¨ãå°æåããå§ã¾ã£ã¦ãã*12ã¨ããçç¾ã
ã³ã¡ã³ãã¢ã¦ããã¦æ®ãã¦ãã
ã³ã¼ããå¤æ´ããã¨ãã«ãã³ã¡ã³ããæ´»ç¨ãããã¨ãåºæ¥ã¾ããã»ã»ã»ä»¥ä¸èªé
コメント (P.91)
ã³ã¡ã³ãã¢ã¦ããã¦æ®ãã¦ãããããããã¼ã¸ã§ã³ç®¡çã·ã¹ãã ã使ã£ãã»ããããã¨æãã
ç·¨éä¸ã®ã³ã¼ãã«ãã¤ãºãã®ããªãããå®ç§ã«å
ã«æ»ããã¨ãåºæ¥ãã
ã³ã¡ã³ãã¢ã¦ããããã£ã½ã©ä¾¿å©ãããªããã
ãã精度ã®é«ãè¨ç®ãè¡ãããå ´å
ããã«é«ç²¾åº¦ã®å®æ°è¨ç®ãè¡ãããã¨ãã«ã¯ãFORTRAN ã®ãããªç§å¦æè¡è¨ç®ç¨ã®ããã°ã©ãã³ã°è¨èªã使ãããåé·ç²¾åº¦æµ®åå°æ°ç¹æ°åã®ãããªé«ã精度ã®å®æ°åã使ãã¾ãã
整数と実数 (P.125)
ãããããã ãã©ãJava ã®æ¨æºã©ã¤ãã©ãªã® BigDecimal ã Commons ã® Fraction ã®ãããªãã®ã使ãã¨ããé¸æè¢ãããã¯ãã
ã¹ãã¼ããªã³ã¼ã
ããã«ãããã©ã³ã使ããããªãã¹ãã¼ã㪠(è³¢ãããª) ã³ã¼ãã®æ¸ãæ¹ã¨ãããã®ãããã¾ããã¹ãã¼ããªã³ã¼ããæ¸ãã¨æ°åãããã®ã¯äºå®ã§ãããã¨ãã«ã¯ããã¦æãè¦ããæ¸ãæ¹ãããå¿ è¦ãããå ´åãããã¾ã
スマートなコード (P.164)
ã¹ãã¼ããªã³ã¼ãã®å®ç¾©ãããããã«ã¹ãã¼ããªã³ã¼ãã®æ¹å¤ãããã¨ã¯ãã¹ãã¼ããããªããªã
C++ è¨èªã§é åã宣è¨ãã¦ããã®è¦ç´ ãåæåããã¨ããä¸è¬çã«ã¯æ¬¡ã®ããã«ããã§ãããã
int a[20]; for (int i = 0; i < 20; i++) a[i] = i;ãããã次ã®ããã«æ¸ããã¨ãã§ãã¾ãã
int a[20]; for (int i = 0; i < 20; a[i++] = i) ;ä¸ã®ä¾ã® for ã¹ãã¼ãã¡ã³ãã®æ¬¡ã®è¡ã® ; (ã»ãã³ãã³) ã¯é£¾ãã§ã¯ãªãã¦ãå¿ è¦ãªãä½ãããªããã¹ãã¼ãã¡ã³ãã§ãããã® ; ã for ã¹ãã¼ãã¡ã³ãã®æå¾ã«ç§»åãã¦æ¬¡ã®ããã«æ¸ãã°ãããã«ãããããè¦ãã¾ãã
スマートなコード (P.165)
ã»ã»ã»ã¢ããããã®ã§çç¥
ã©ãããæ¥åããã®ãããããããã¯ä¸éä¸è¬ã®ãããããããã¨ã¯ããã¦ãããããªããããã
ãã®ã³ã¼ãã§ããããããåºãã¨ãããã
- 20ã¨ãããã¸ãã¯ãã³ãã¼ã«ååãä»ãã
- å¾ç½®ã§ã¯ãªãåç½®ã®ã¤ã³ã¯ãªã¡ã³ãã使ç¨ãã
- é åã®å¤ããã« std::vector çã使ç¨ãã
ã¨ããããããæ¹åãªããããªãã®ï¼
ããªãé·ããªã£ããã©ãããã§ãä¸å¿ãã»ãªãªã¼ããã¯ãã·ãªã»ãã ã¨æãã
ãã ãã»ãªãªã¼ã¯ãééã£ã¦ãã¨ãããããªãã£ããã¨ãããã»ã©ãã©ããééã£ã¦ãããªãã¦æ°ã«ããã«å
¨é¨ééã£ã¦ãã¨æã£ã¦èªããã¨ã¯åºæ¥ããã ãã©ããã®æ¬ã¯æ£ãããã¨ãæ¸ãã¦ããåããã¡ã¯æªãããã
æ¥æ¬äººã«ã¯ããããããå
¥éæ¸ã®æ¬¡ã«èªãæ¬ãã¯æ¸ããªãã»ããããã®ãããã
Java ãªã Effective JavaãC++ ãªã C++ in Depth ã·ãªã¼ãºãJavaScript ãªããµã¤æ¬ã¨ããã£ã±ãè¨èªå¥ã«ã次ã®æ¬ããèªãã°ããã¨æãã
*1:éä¸æ¶ãã¡ãã£ã¦ãé¨åããã£ãã®ãæ®å¿µã»ã»ã»
*2:ãä»ã®ãããã°ã©ãã³ã°ã®å¸¸èãã«é¢é£ããæ¸ç±ã®å 容æ¯è¼ãå«ãã¦ãã£ã¦ãClean Code ã¨ãã¨ã®æ¯è¼ããæã¿ãªã®ãï¼
*3:å°æ¥ã®çãã»ã»ã»ä¸é¨ã®æ¸ãç´ããããã¾ãªãã¨æããã©ã©ãã ãããææäºé ãä¿®æ£ãããããã¯ãå¥ã®æ¬ã§ãããã
*4:ããæå³æ¬ã«è¼ã£ã¦ãã®ã¯å ·ä½çãªä¾ã ãã©ããã®æ¬ã®èªè 層ãèããã¨æ°ä»ããªãã¨æã
*5:C è¨èªã®ç¿å¾ã容æãã©ããã¯æ°ã«ãªãã¨ããã ãã©ã»ã»ã»C è¨èªåãããªãï¼
*6:ã¡ãã£ã¨èªä¿¡ãªã
*7:C ã«ã¯è©³ãããªãããããããªã
*8:å¼æï¼å¼æã¯å¼ãããªãã¦æã ããåã
*9:ã¾ãè¨æ¸¬ãã§ãæé©åãã§ãè¨æ¸¬ãã¦æ¬å½ã«éããªã£ãã確ããã
*10:ä¾å¤ã¯ãããã©ãããã¾ã§ä¾å¤
*11:æã®èªåã¨ãï¼
*12:ããã ããããªãã¦ã¯ã©ã¹åã«å¤§æåã使ããã¦ããªã