C ++中奇怪的类型不匹配

时间:2012-02-23 11:37:45

标签: c++ types const

我需要一些帮助,这样的类型不匹配怎么可能? 当我替换所有内容时,它的类型完全相同 常量性。

cgVertex3D.cpp:33: error: no matching function for call to 
std::vector<Polygon3D*, std::allocator<Polygon3D*> >::push_back(const Polygon3D*&)

/usr/include/c++/4.4/bits/stl_vector.h:733:
note: candidates are: 

void std::vector<_Tp, _Alloc>::push_back(const _Tp&) 
[with _Tp = Polygon3D*, _Alloc = std::allocator<Polygon3D*>]
<near match>       

1 个答案:

答案 0 :(得分:6)

_Tpconst,在这种情况下_Tp是指针。因此,const _Tp的替换实际上会导致Polygon3D *const,而不是const Polygon3D *,因此不匹配。