阅读背景:

在c++中初始化动态数组的正确方法

来源:互联网 

I'm currently working on a C++ project, where dynamic arrays often appear. I was wondering, what could be the correct way to initialize a dynamic array using the new-operator? A colleague of mine told me that it's a no-no to use new within the constructor, since a constructor is a construct that shouldn't be prone to errors or shouldn't fail at all, respectively. Now let's consider the following example: We have two classes, a more or less complex class State and a class StateContainer, which should be self-explained.I'm currently working on a C++ project, where d




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: