info

C++

2Dゲーム用の重力計算モジュール作った、google test試しに使ってみた

moveable.hh #include <cmath> #ifndef _MOVEABLE_H_ #define _MOVEABLE_H_ namespace moveable { //いろいろな定数値、後でcommon.hに入れてもらう const float PI = static_cast<float>(atan(1.0) * 4); const float RAD = PI / 180;//HACK 30度 = 1/6ラジアン const flo</float></cmath>…

ICPCのdpcmデコード問題解いた

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=2199問題解いた物を改造してコードを読みやすくして、標準エラーに最小二乗和、標準出力にデコードしたバイナリを吐くようにした ここのファイルをデコードするとノイズの後、ゆっくり…

関数ポインタを使ったお手軽なStrategyパターン

「Rubyによるデザインパターン」にのってるコードをC++に翻訳中 関数ポインタつかうと、いろいろpublicにしなきゃならんのねReport.hpp #include <string> #include <vector> using namespace std; class Report { public: Report (void (*)(Report&)); void output_report (</vector></string>…

あっびゃっばばのためにテンプレートを使うStrategyパターン

-Weffc++?後回し!Report.hpp #pragma once #include <string> #include <vector> using namespace std; template <class T> class Report { public: Report (T*); void output_report (); string title; vector<string> text; private: T* formatter; }; template <class T> Report<T>::Report (T *inform</t></class></string></class></vector></string>…

静的言語らしく基底クラスを作るStrategyパターン

-Weffc++したらすごい警告出た、あばばばば #pragma onceは甘え プロトタイプ宣言とか型指定する時classって明示しなきゃコンパイル通らなかった、どこがおかしいかわからんReport.hpp #pragma once #include <string> #include <vector> #include "Formatters.hpp" using na</vector></string>…