以下内容不能用g ++ 4.4.7编译,在命令行上传递了--std == c ++ 0x:
#include <algorithm>
#include <iostream>
template <typename T>
class A
{
public:
T v;
A() { std::cout << "A default constructor\n"; }
A(const A& i): v(i.v) { std::cout << "A copy constructor\n"; }
A(A&& i): v(std::move(i.v)) { std::cout << "A move constructor\n"; }
#if 1 // turn this off to fix the version without static_cast
template <typename V>
explicit A(const V& i): v(i) {}
#endif
};
class B: public A<int>
{
public:
B() { …Run Code Online (Sandbox Code Playgroud)