2009-05-29から1日間の記事一覧

C++ Coding Standards

C++

C++ Coding Standards―101のルール、ガイドライン、ベストプラクティス (C++ in‐depth series)作者: ハーブサッター,アンドレイアレキサンドレスク,浜田光之,Herb Sutter,Andrei Alexandrescu,浜田真理出版社/メーカー: ピアソンエデュケーション発売日: 200…

適当にauto_ptrを実装する

C++

#include <iostream> #include <string> using namespace std; template<class T> class AutoPtr { T *p_; public: AutoPtr(T *p) { cout << "new:" << this << endl; p_ = p; } ~AutoPtr() { cout << "delete:" << this << endl; if (p_) { cout << "!!delete object!!" << endl; delet</class></string></iostream>…

cygwin, gcc4, tr1

C++

このソースが一応、cygwinでもビルドできた。 #include <iostream> #include <tr1/functional> using namespace std; int count1(int n) { return ++n; } int count2(int &n) { return ++n; } int count3(int *n) { return ++(*n); } int main() { int n1 = 0, n2 = 0, n3 = 0; tr1::fu</tr1/functional></iostream>…