【发布时间】:2012-10-02 13:13:04
【问题描述】:
所以,我有这种情况:
vector<vector<double>> myVector;
myVector.resize(somePreviousObject.size());
for(int i = 0; i < myVector.size(); i++)
{
vector<double> tempVector;
//Do some stuff that fills tempVector, in a loop
//After loop:
myVector[i].push_back(tempVector);
}
但是,这会产生一个编译错误,说明:
no matching function for call to 'std:;vector<double, std::allocator<double > >::push_back(std::vector<double, std::allocator<double> >&)'
...stl_vector.h:733 note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = double, _Alloc = std::allocator<double>]
我意识到使用向量的向量对性能不友好,但它仍然应该编译和执行,对吗?为什么不呢?
感谢您的帮助。
【问题讨论】:
标签: c++ vector compiler-errors