所以,我有这种情况:
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>]
我意识到使用向量向量对性能不友好,但它仍然应该编译和执行,对吗?为什么不呢?
谢谢你的帮助。