- 追加された行はこの色です。
- 削除された行はこの色です。
[[FrontPage]]
* C++
// * C++
#contents
** template
* 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/default.asp?url=/japan/msdn/library/ja/jpdndeepc/htm/deep08032000.asp
-- とりあえず typedefのテンプレートはできない
** stringstream
* stringstream
- strstream の新しい版?
- #include <sstream>
** string::resize
* string::resize
"\0\0..." になってる?
** コンストラクタとg++(3.3.5)とboost::shared_ptrな怪しい関係
* コンストラクタと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()