I was wondering if its possible to create variable names which are linked to my class in a loop using the stringstream?
For example i have this:
for(int i=1; i<6; i++){
std::stringstream button;
button << "Button" << i;
CreateButton button();
button.function_name();
}
When i tried it I could not access the function for that class.
The function is not available… so I’m wondering if I am just overwriting the string stream. If i am is there a way to do what I am trying to do?
You want an array or vector of buttons.
Here you can think of
button[0]as one variable, andbutton[1]as another variable,button[2]as yet another variable, and so on. In this way, you have six variables.