// * C++ #contents * template - ヘッダとソースを分ける(明示的なインスタンス化) -- http://www.fides.dti.ne.jp/~oka-t/cpplab-template-3.html - template <typename T> typedef T1<T2<T> > T12<T> なことについて -- [[http://www.microsoft.com/japan/msdn/library/...>http://www.microsoft.com/japan/msdn/library/default.asp?url=/japan/msdn/library/ja/jpdndeepc/htm/deep08032000.asp]] -- とりあえず typedefのテンプレートはできない * stringstream - strstream の新しい版? - #include <sstream> * string::resize "\0\0..." になってる? * コンストラクタとg++(3.3.5)とboost::shared_ptrな怪しい関係 どれが悪いのかわからんが class Foo { boost::shared_ptr<Qux> member; Foo(Bar bar) { Foo(bar.baz()); // ここで失敗する ASSERT(member.get()); } Foo(Baz baz) { member.reset(new Qux()); } }; init(Baz)とか言うメソッドを作って Foo(Baz)の処理をそのまま移せば問題なし。 * オーバーロードは動的ではない #include <iostream> using namespace std; class Base { public: virtual void foo() { cout << "Base::foo()" << endl; } }; class Derived : public Base { public: virtual void foo() { cout << "Derived::foo()" << endl; } }; void foo(Base &base) { cout << "foo(Base &)" << endl; base.foo(); cout << endl; } void foo(Derived &derived) { cout << "foo(Derived &)" << endl; derived.foo(); cout << endl; } int main() { Base b; Derived d; Base *ptr = &d; Base &ref = d; foo(b); foo(d); foo(*ptr); foo(ref); } foo(Base &) Base::foo() foo(Derived &) Derived::foo() foo(Base &) Derived::foo() foo(Base &) Derived::foo() * オーバーロードと デフォルト引数と char* void foo(const std::string &str, bool flag=false); void foo(bool flag=false); char *p; foo(p); char*はstd::stringではなくboolとしてみられるので後者が呼ばれる。~ g++ 3.3.6~