rabbitfoot530's diary

読んだ本と、プログラムに関することのメモです。好きな言語は、C++, Python, Golang, TypeScript。数学・物理・学習理論も好きです。

2012-03-28から1日間の記事一覧

boost::function

要は、関数ポインタね♪ #include <boost/function.hpp> int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } int main() { boost::function<int (int, int)> f = add; Print::p(f(1, 2)); f = sub; Print::p(f(1, 2)); }</int></boost/function.hpp>

templateのヘッダ

C++

tepmlateを書くときは、ヘッダに実装も書かないといけない。けど、宣言が書いてあるヘッダに、実装が書いてあるヘッダを別ファイルとしてincludeすれば、実装と宣言を分けることができる。inc_header.hpp #include "imp_header.hpp" template <typename T> void(T m); te</typename>…