简体   繁体   中英

How to get declared variables with specific number at the ends c++

I have void function:

void setPreyFreeReroll(uint8_t column, uint32_t value) {
    rerollTime << column = value;
}

rerollTime variable is defined as rerollTime0, rerollTime1, rerollTime2. "column" is number 0,1,2 how do I get variable with this number? Using it like I try is getting me error undefinied variable.

reroll variables:

uint32_t rerollTime0 = 0;
uint32_t rerollTime1 = 0;
uint32_t rerollTime2 = 0;

in all honesty your code is so far from being c++ it is hard to tell exactly what you are trying to accomplish.

uint32_t rerollTime[3];

void setPreyFreeReroll(uint8_t column, uint32_t value) {
    rerollTime[column] = value;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM