【发布时间】:2015-12-10 21:16:05
【问题描述】:
我有两个类 Dot 和 Point 做同样的事情。 它们只是来自两个不同的库,我必须同时使用它们。
我希望能够做到:
Dot d;
Point p = d;
std::map<Dot, int> m;
m[p] = 1;
我无法修改库源代码。
我的想法是在我的实现中添加一些运算符...但我遗漏了一些东西,我无法编译我的代码。
我只有很多
error: prototype for 'void Dot::operator=(const Point&)'
does not match any in class....
有什么提示吗?
谢谢
【问题讨论】:
-
用
m[d]替换m[p]?
标签: c++ operator-overloading operators