Quote:
Originally Posted by dmail
Have you overloaded the equal operator? otherwise you are trying to reset a reference which is not allowed. There are many more questions I could ask but I think it maybe better to see your code.
|
Well this is actually almost the same thing I wanted when I created this thread, just that now I am parsing a file and the first word on a certain line contains a word that will be converted into a number.
So I have a function which converts a list of text strings to a number between 0 and 12. Just like when you #define stuff, just that now I can't use the preprocessor.
Anyway, I realized that if a person starts to modify the file he or she may not write each line in order. Well, I will try to explain a little better:
The file looks like this:
Code:
# comments
[ModelName]
STAND VX_HEAD 0 1 2 3
STAND VX_HEAD 1 2 3 4
STAND VX_HAND 0 1 1 1
STAND VX_LEG 0 3 2 1
WALK VX_HEAD 0 1 1 1
WALK VX_HAND 0 2 1 4
...
[AnotherModelName]
...
I then parse the file, the first word is the state, which translates into a number. I need the index number in the vector to reflect to that number. So if STAND is 3 and WALK is 2, I need the verteces for STAND to be added to the 3rd index in the vector (the vector contains a number of instances of the class ModelAniType, where each instance takes care of a certain state, like walk or stand).
I could have solved this with push_back, but that requires that the state that translates into 0 should be first in the file, next the state that translates into 1, and so on. So that the ModeAniType instances get pushed onto the vector in the correct order.
I need something more dynamic than that. So I want to make the vector grow as it needs and then play with the item at index function_state2int(STATE).
Does anyone understand what I am talking about? :P
Thanks,