哪個是調用基類移動ctor的正確方法?調用基類移動ctor [C++ 0x]
這(在MSVC2010作品,但不是在CBuilder2010):
struct Foo
{
Foo(Foo&& other) { }
};
struct Bar : public Foo
{
Bar(Bar&& other) : Foo((Foo&&)other) { }
};
或(在CBuilder2010工作,但不是在MSVC2010):
struct Foo
{
Foo(Foo&& other) { }
};
struct Bar : public Foo
{
Bar(Bar&& other) : Foo(&other) { }
};
,或者是他們都錯了嗎?如果是這樣,什麼是正確的方式(根據C++ 0x標準中規定的內容)?
注意:我無法弄清楚如何讓它在CBuilderXE中工作(兩個版本都不起作用)。
'Foo(&other)'不應該編譯,除非Foo有一個需要Foo指針的ctor。 – 2010-11-01 13:25:26