I want to enter numbered objects into an array. Each object's element has to be numbered depending on its position on the array. I can't figure out why the string index keeps the previous values when it is converted as the loop goes on. For example. First place is 0 and as the loop goes on its becomes 01,012,0123 and so on. here's that part of the code I have problem with
stringstream convert;
int N;
int k;
srand ((long) 123456);
N=rand()%100+1;
NewTable=new Employee[N];
for(k=0;k<N;k++){
string name,surname,number="";
convert<<k;
number=convert.str();
cout<<number;
name="John_"+number;
surname="John_"+number;
NewTable[k].SetEmployee(name,surname,13*k,3*k);*/
}
I also thought that by reinitializing the string of the number at the the start of the loop it will solve the problem, but it didn't.