【发布时间】:2026-01-23 10:45:01
【问题描述】:
我想编写一个类来管理欧几里得向量并使用 short、int、long 或 float 存储其初始点。我想创建一个这样的模板:
template<class unit> class EVector
{
private:
unit x;
unit y;
public:
EVector();
setX();
setY();
};
所以用户创建了一个 EVector 来选择合适的原始类型。但是如何实现不同类之间的操作,例如
EVector<int> a;
EVector<float> b;
EVector<double> c;
c = a + b;
operator= 将复制坐标,operator+ 添加它们。
【问题讨论】:
-
这个问题似乎与*.com/questions/1629829/…类似,它可能对你有用。
-
那么问题是什么?
标签: c++