无规范的动态数组

class test
{
public:
private:
int b;
int *a;
a=new int[b];
}
在其他稀奇古怪的地方这样写会大幅拖延加载速度(但还能运行)

没有delete

未初始化的动态数组

class test
{
public:
test()
{
a=new int[b];
}
private:
int *a;
int b;
}
b的大小未知,就算为0,也要寄,一般跑不通,偶尔有报错信息

访问越界

class test
{
public:
test()
{
b=2;
a=new int[b];
for(int i=1;i<=b;i++)
}
private:
int *a;
int b;
}
指针i就访问越界

指针悬挂

在询问动态数组前动态数组就释放了的问题

class a{};
void test(a test)
函数结束后,test内的动态数组会释放,此时外界的指针会悬空。要传入&
--------------------------------------------------
class b
{
class a;
};
若a先于b被析构,那么b的析构就会悬挂

建议使用vector(

建议delete后补充=nullptr

~a()
{
if(ptr!=nullptr)
delete []ptr;
ptr=nullptr;
}

建议速速💤(古神嘶鸣)