タグ

2011年6月19日のブックマーク (1件)

  • J[funcgui]

    C++の好きな指定子が inline で、inline は「インライン展開する」という意味ではないというのが好き。 「インライン展開する」という意味で inline を使うとしたら、 #include <stdio.h> #include <stdlib.h> inline int fibonacci(int x) { if (x <= 1) { return x; } return fibonacci(x-2) + fibonacci(x-1); } int main(int argc, char **argv) { printf("%d\n", fibonacci(atoi(argv[1]))); } こういう再帰がいるような関数だとインライン展開できずにエラーになるはずである。 実際にはもちろんこれはエラーではない。 仕様を読んだことはないので厳密な定義は知らないが、inline

    J[funcgui]
    yshl
    yshl 2011/06/19
    醤油とソースを任意のタイミングで交換するブログ