How can I create a dynamically sized array of structs?

后端 未结 10 1205
春和景丽
春和景丽 2020-11-27 11:46

I know how to create an array of structs but with a predefined size. However is there a way to create a dynamic array of structs such that the array could get bigger?

<
10条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 12:24

    Here is how I would do it in C++

    size_t size = 500;
    char* dynamicAllocatedString = new char[ size ];
    

    Use same principal for any struct or c++ class.

提交回复
热议问题