vendredi 28 octobre 2016

How to access members of a class with dynamic names Cocos2d-x C++

I have some numbers in my header that I want to access in the code like this.

int _number0;
int _number1;

Then in implementation

_number0 = 10;
_number1 = 20;

int i;
for(i=0; i<2, i++){
    auto number = _number+i; //This is where I'm lost, how to do the right part right in order to get this int by its name created from a String + an Integer.
    CCLOG("Number: %i", number); //Output Number: 10 // Number: 20
}

Thanks for any guideline. Greetings.

Aucun commentaire:

Enregistrer un commentaire