我很难找到关于这些东西的信息!:(
我不明白为什么这个不起作用:
vector<B*> b;
vector<C*> c;
(B and C are subclasses of A)
(both are also initialized and contain elements etc etc...)
template <class First, class Second>
bool func(vector<First*>* vector1, vector<Second*>* vector2)
return vector1 == vector2;
编译时会返回以下结果:
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
我认为这应该是可行的,指针保存地址对吧?那么为什么不直接比较两个向量指针是否指向同一个地址呢?
reinterpret_cast<>
可以根据类型自由更改实际数值。 - user529758func(b, b)
。 - optional