Using the loop integer to define variables: c++

前端 未结 3 1458
忘掉有多难
忘掉有多难 2021-01-16 12:09

I have a for-loop which runs over i. For every iteration, I wish that it creates a variable with the name var_i i.e if my loop runs over i=0<

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-16 12:51

    You can't create variables at runtime. Use std:vector instead so you'll get var[0], var[1], etc.

提交回复
热议问题