include <iostream>
template<typename DTTYPE>
class Base
{
public:
Base(){};
Base(const Base &bt, const DTTYPE &scale = 1.0){std::cout<<"base copy"<<std::endl;}
Base(Base &&bt, const DTTYPE &scale = 1.0){std::cout<<"base move"<<std::endl;}
};
template<typename DTTYPE>
class Sed : public Base<DTTYPE>
{
public:
Sed(){};
Sed(const Sed &sd, const DTTYPE &scale = 1.0) : Base<DTTYPE>(sd, scale) {std::cout<<"copy sed"<<std::endl;}
Sed(Sed&& sd, const DTTYPE &scale = 1.0) : Base<DTTYPE>(sd, scale) {std::cout<<"move sed"<<std::endl;}
};
int main(void)
{
Sed<double> a;
Sed<double> b(std::move(a));
return 1;
}
运行结果输出: base copy
move sed
调用了基类的拷贝构造函数而不是移动构造函数。怎么才能调用基类的移动构造呢?
谢谢!
--
FROM 210.26.112.*