如何重写模板模板特化的功能?
我正在用 vector 的 vector 构建一个 C++11 矩阵。我已经实现了 vector (不能使用 std::vector
)并且我希望矩阵继承自 myVector<myVector<T>>
. myVector<T>
工作正常,但是 myVector<myVector<T>>
有一些我想覆盖的功能(删除它们)。我该怎么做?
代码:
template <typename T> class myMatrix : public myVector<myVector<T>>{
...
//scalar multiplication
myVector<T> MyVector<T>::operator*(const T& scalar) const{...}
}
我想删除operator*
功能仅来自 myVector<myVector<T>>
特化(这样 myVector<int>
实例将能够使用函数,但 myVector<myVector<int>>
实例不能)。
最佳答案
也许使用删除?
class A
{
public:
A(){;};
int some_function();
};
class B: public A
{
public:
B():A(){;};
int some_function() = delete;
};
关于c++ - 如何专门化模板模板的功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54207499/