小编use*_*602的帖子

子类坚持调用模板而不是构造函数

以下内容不能用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)

c++ templates copy-constructor c++11

4
推荐指数
1
解决办法
170
查看次数

标签 统计

c++ ×1

c++11 ×1

copy-constructor ×1

templates ×1