STL: how to overload operator= for <vector> ?
- by MBes
There's simple example:
#include <vector>
int main() {
vector<int> veci;
vector<double> vecd;
for(int i = 0;i<10;++i){
veci.push_back(i);
vecd.push_back(i);
}
vecd = veci; // <- THE PROBLEM
}
The thing I need to know is how to overload operator = so that I could make assignment like this:
vector<double> = vector<int>;
I've just tried a lot of ways, but always compiler has been returning errors...
Is there any option to make this code work without changing it? I can write some additional lines, but can't edit or delete the existing ones. Ty.