У меня есть вектор вектора, который содержит только периоды ("."), И я хочу заменить определенные координаты на сетке символом, который я беру с входа файл. Я использую метод замены, но продолжаю получать эту ошибку.заменяющие элементы в векторе векторов 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;
}
}
'станд :: replace' принимает итераторы. – chris