vector.push_back(string) Doesn't work???

Hey there,

I got a problem with the push_back function of a vector to fill it with strings.

This is the code:
labelVector.push_back(labelString);

labelString works fine, but the labelVector just wouldn't get longer. It always has the size 1 and if I take it out of the class via a getter function

vector<string> openAssembler::getLabelVector(){
return labelVector;
}

it's size suddenly turns out to be 0.
Anybody has a clue what that could be?

Hope you guys can help me.

Thanks!
Last edited on
Write a complete example that compiles so that we can see the problem duplicated that way.
Does your implementation of push_back look like this?

1
2
3
4
5
template<typename T>
void Vector<T>::push_back(T value)
{
  return array[size++] = value;
}


Of course in your case the T would represent string.
closed account (zb0S216C)
Of what type is labelString?

1
2
3
char *labelString;       // Is it this one?
char labelString[...];   // This one?
string labelString;      // Or this one? 
Last edited on
Topic archived. No new replies allowed.