使用std :: copy將1D矢量轉換爲2D矢量時,出現了編譯錯誤。將1D矢量轉換爲2D矢量
int main()
{
std::vector< std::vector<float> > v2D(10, std::vector<float>(10, 0.0));
std::vector<float> v1D(100, 0.0);
for (int i = 0; i < 100; ++i)
v1D.push_back(i);
for (unsigned int j = 0; j < 10; j++)
{
std::copy(v1D.begin() + j * 10, v1D.begin() + (j + 1) * 10, std::back_inserter(v2D[j].begin()));
}
}
請您幫忙解決這個問題嗎?謝謝。
錯誤信息是什麼意思? – 2011-06-03 02:31:50