小编bob*_*bob的帖子

如何破坏数组

#include <cstdlib>
#include <iostream>

using namespace std;

const unsigned long MAX_SIZE = 20;
typedef int ItemType;

class Heap {
private:
        ItemType array[MAX_SIZE];
        int elements; //how many elements are in the heap
public:
      Heap( )
       ~Heap( )
       bool IsEmpty( ) const
      bool IsFull( ) const
      Itemtype Retrieve( ) 
      void Insert( const Itemtype& )
};
Run Code Online (Sandbox Code Playgroud)

假设我将此作为我的头文件.在我的实现中,做Heap()构造函数和~Heap()析构函数的最佳方法是什么.

我有

Heap::Heap()
{
   elements = 0;
}

Heap::~Heap()
{
   array = NULL;
}
Run Code Online (Sandbox Code Playgroud)

我想知道这是否是在这种情况下破坏和构造数组的正确方法.

c++ arrays

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×1

c++ ×1