How to create an array when the size is a variable not a constant?

后端 未结 6 1804
半阙折子戏
半阙折子戏 2020-11-27 19:31

I\'ve got a method that receives a variable int. That variable constitutes an array size (please, don\'t offer me a vector). Thus, I need to init a const int inside my metho

6条回答
  •  孤街浪徒
    2020-11-27 19:53

    If you're using arrays it's a good idea to encapsulate them:

    template
    class Vector {
        //...
    };
    

    The standard library comes with an implementation: std::vector

提交回复
热议问题