Tensor rank problem when implemented in C++

  c++, math, mathematical-optimization, oop, tensor

I need to implement an arbitrary rank tensor (the number of dimensions is entered by the user). How do I iterate if I don’t know the rank of the tensor in advance? For example, to implement tensor transposition, only nested "for" loops come to mind, but this cannot be done without knowing the number of dimensions in advance. What do i do?

Source: Windows Questions C++