0
我有僅包含週期 (「」)矢量的矢量到目前爲止我想和我正在從輸入取入一個符號,以取代對電網某些座標文件。我正在使用替換方法,但不斷收到此錯誤在矢量的矢量替換元件C++
" error: no matching function for call to replace(std::basic_string, std::allocator >&, std::basic_string, std::allocator >&, const char [2], const char*)"
我不確定那個錯誤的含義。我感謝任何和所有的幫助。在這裏先謝謝
是我的代碼
#include <vector>
#include <string>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
string locationfilename, filenames,symbol;
int numRows, numCols, startRow, startCol, endRow, endCol, possRow, possCol, id;
cout<< "Enter Locations Filename"<<endl;
cin>>locationfilename;
cout<< "Enter Names Filename"<<endl;
cin>>filenames;
ifstream locations(locationfilename.c_str());
ifstream names(filenames.c_str());
locations>>numRows>>numCols>>startRow>>startCol>>endRow>>endCol;
vector <string> rows(numCols,".");
vector< vector<string> > grid(numRows,rows);
locations>>possRow>>possCol>>symbol>>id;
while(!locations.fail())
{
if(possRow>numRows || possCol>numCols)
{
cout<<id<< " out of bounds-ignoring"<<endl;
}
else
{
replace(grid.at(possRow).front(),grid.at(possRow).back(),".",symbol.c_str());
}
locations>>possRow>>possCol>>symbol>>id;
}
}
'的std :: replace'採取迭代器。 – chris