ããã¶ãåã®è¨äºã«åå¿ãã¾ããã
â [misc]Cã¯ã¯ã³ãã³åãã ã¨èããããã«ãªã£ãã
ãããããã¾ã§èªåã®ä¸ã§ã¯ã§ãã
ä»ãCã§ä½ããããã®ãåèã«ãã¦C++ã«ç§»ãä½æ¥ããã¦ããããããã ããã©ãã
è³ãæã«åºç¾ããã
void*
ã³ã¼ã«ããã¯
è¬ãã©ã°
hoge->foo->bar->ptr
Cããä»ã®è¨èª(Javaã¨ãC#ã¨ã?)ã«æ¯ã¹ã¦ã¨ã«ããããå§åçã«ãã¡ãªã¨ããã¯ã
- å®è¡æã®ãã§ãã¯ããªãããã£ã¦ãé åã®ãªã¼ãã¼ã©ã³ãä¸æ£ãªãã£ã¹ããéæ¾ãããã¡ã¢ãªãåç §ãããã¨ãã£ãçç±ã§ã®ãã°ãçºçããåå 追åãé常ã«å°é£ã
- GCããªãã
ã®2ç¹ã§ããã(ç¹ã«åè )ãC++ã§ã¯ãã®2ç¹(ç¹ã«åè )ã«ã¤ãã¦ã¯ãæ¸ãæ¹æ¬¡ç¬¬ã§ãã·ã«ãªãã¨ã¯ãããå®å ¨ã«è§£æ±ºããã¦ã¯ãã¾ããã
ã§ãIsoparametricããã®è¨ãã¨ããã®åé¡ç¹ã§ããã
void*
void*ã¯è³ãæã§ä½ãã«åããã
ã¾ããã®ã¨ããã§ãããããã¯Javaã¨ãã§Objectã使ã£ã¦ãåããã¨ã§ãããGenericsãªãtemplateãªãã使ãã°å¥ã§ããã
C++ãªããããªãåããtemplateã¯ãã£ãã®ã§ãC++ã¦ã¼ã¶ã®Isoparametricãããããã«ä¸æºãæã¤ã®ã¯ã¾ãããããªãã¯ãªãã§ãã
Cã«åºæã®åé¡ã¨è¨ããªãããããchar*ã§å¥½ãåæãªã¡ã¢ãªã¢ã¯ã»ã¹ãè¡ãããã°ã©ã ãããªãããªãã
ã³ã¼ã«ããã¯
StateãStrategy風ãªãã¨ããããã¨ãã¦ã³ã¼ã«ããã¯ã®åµã«ãªããã ããã©ãã
ãã£ã¡ããã£ã¡ããã£ã¡ã«é£ãã ããã¦é·ç§»ãèªã¿ã¥ããã
StateãStrategy風ãªãã¨ããããã¨ããCããã°ã©ãã£ã¦ãç¸å½ã«æèãé«ã人ã®ããã«æãã¾ããã¾ããçµæã¨ãã¦ããã°ã©ã ãèªã¿ã«ãããªã£ã¦ã¯æå³ããªãã®ã§ããã
ããã¯ãã¦ãããC#ã®delegateãªãã¦é¢æ°ãã¤ã³ã¿ãã®ãã®ã ããå®è¡æã«åããå¤ãããã¦interfaceãã¶ã£æ¿ãããããªã¢ã«ãã£ãºã ã使ããªãã¦ãã¨ã¯ãããOOè¨èªã®æ¹ããããããã¨ãããã¦ãããã£ã¡ããã£ã¡ããã£ã¡ã«é£ãã ããã¦é·ç§»ãèªã¿ã¥ãããã®ã¯ããããã®æ¹æ³ã§ãåæ§ã«çºçãããã¨ã§ãã
大æããããªã®âãæ¸ãã¾ãããã
新プログラミング言語「BF-BASIC'n」
ãã¾ã¤ãããOOè¨èªã§ã¯ãããªã¢ã«ãã£ãºã ã¨ããæ©è½ã«ããé©ç¨ãããæç¶ãããå®è¡æã«æ±ºã¾ãã®ã§ããããããã°ã©ã ã®ã½ã¼ã¹ãèªããã¨(éçãªè§£æ)ã¯ã¾ãã¾ãå°é£ã«ãªã£ã¦ãã¾ã£ã¦ãã¾ãã Cãªã©ã§ã¯ãããé¢æ°ã®ã½ã¼ã¹ãèªãéãç®çã®é¢æ°ããã©ãã©ãä¸ä½ã¸ã¨æãé²ãã¦ããã°ããããã§ããã OOè¨èªã§ã¯ãã¤ã³ã¹ã¿ã³ã¹ãã£ã¼ã«ããªã©ã«ä¿æããã¦ãããªãã¸ã§ã¯ãã®ã¡ã½ãããå¼ã°ãã¦ãããããã®ãªãã¸ã§ã¯ããçæããã¦ããã¨ããã¾ã§é¡ã£ã¦èªãå¿ è¦ãããã¾ããããããã½ã¼ã¹ãé¡ã£ã¦èªããã¤ã¾ããã©ã®å®è¡ãã¹ãéã£ã¦ããã«æ¥ãããæ¢ããã¨ã¯ãåã«å®è¡é ã§èªãã§ããã®ã«æ¯ã¹ã¦å§åçã«é£ãããã®ã§ãããããã©ãããããã£ã¨æ¢ãå½ã¦ããªãã¸ã§ã¯ãã®çæç®æ㧠ãã¶ã¤ã³ãã¿ã¼ã³ãªãã使ããã¦ãããããã¨ãããã«ããããé·ãæ ã®å§ã¾ãã§ãã
ã¨ã¤ããªã«ãã¼ã«ãã¿ã¨ã¯ãããä¸è¨è¨è¿°èªä½ã¯ãããªãã«çå®ã ã¨æãã¾ãããã¡ãããã ããOOãæªãã¨ããã®ã§ã¯ãªããéçã«ã½ã¼ã¹ã追ããã¨ãé£ãããªã代ããã«æè»æ§ãå¾ã¦ããã®ã§ããã
è¬ãã©ã°
è³ãã¨ããã«ããhoge_flag & HOGE_FOO_BARã
ãã©ã°ã®ååã ãã§ã¯ä½ããã¦ããã®ãããããªããâ¦â¦ãorz
isHogeã¨ãcanHogeã¨ãhasHogeã¨ããªãããããã ãã©ã
ãã¹ã¦&ã|ã~ã§ããããã¨ããããã
ååã®åé¡? ããã¨ããããæ¼ç®ã®åé¡?
ååã®åé¡ãªãCé¢ä¿ãªãã¦æ¸ããããã°ã©ãã®åé¡ã ãããããæ¼ç®ãããããªãã®ã¯Isoparametricããã®åé¡ãªã®ã§ã¯ã
hoge->foo->bar->ptr
æãã¦ããå ããããããã«ã¯ãã¹ã¦è¿½ã£ã¦ãããªãã¨ããããªãã
C++ã ãããJavaã ãããC#ã ããããããã«ã¤ãã¦ã¯äºæ ã¯ã¾ã£ããåãã§ã¯? (ã->ãã§ã¯ãªãã.ããªãããã£ã¦åé¡ã§ããªãã§ããã)
# Cã®å ´åããã¤ã³ã¿ã®ãã£ã¹ããéæ¥æ¼ç®å(*)ã使ãããã¨ãåç½®ãªã®ã§æ»ã£ã¦
# èªã¾ãªããã°ãªããªãä¸ã«ç¡é§ãªæ¬å¼§ãåºã¦ãããã¨ããä¸é½åã¯ããã¾ãã
# ã§ããåºã¦ããä¾ã¯ããããä¾ãããªãããªãã