+ 1

Why “queue=new A[100];” cannot replace by “A queue[100];”?

template <typename A> class Queue { int size; A* queue; //定义一个指针变量,它的类型由生成实例时的参数决定 //int* queue; public: Queue() { size = 0; queue=new A[100];//此处不能写成 A queue[100];会溢出和报错 } …};

12th Jun 2021, 4:54 AM
BIGBEN
BIGBEN - avatar
1 Réponse
+ 1
What are they different?
12th Jun 2021, 4:54 AM
BIGBEN
BIGBEN - avatar