2013-06-25 108 views
0

我提出如下─无法访问功能

 #include<iostream> 
    using namespace std; 
     /** 
     * Construct the binary heap. 
     * capacity is the capacity of the binary heap. 
     */ 

class BinaryHeap 
     { 

      private: 
      int currentSize; // Number of elements in heap 
      int array[];  // The heap array 

      void buildHeap(); 
      void percolateDown(int hole); 
      public: 
      bool isEmpty() const; 
      bool isFull() const; 
      int findmini() const; 

      void insert(int x); 
      void deleteMin(); 
      void deleteMin(int minItem); 
      void makeEmpty(); 



     public : 
     BinaryHeap() 
     { 
     currentSize = 0; 
     } 
     BinaryHeap(int capacity) 
     { 
      array[capacity + 1]; 
     currentSize = 0; 
     } 
}; 
int main() 
{ 
    int resp, ch, choice; 
    int n, i; 
    cout << "enter the size of heap" << endl; 
    cin >> n; 
    BinaryHeap b(int n); 
    cout << "enter the item " << endl; 
     cin >> ch; 
    b.insert(int ch); 


return 0; 
} 

给出二进制堆的程序在编译它给误差的部件在“B”“插入”

请求,这是无级的型“二叉堆(INT)”
和 预期的“廉政”前基本表达式

这究竟是为什么以及怎么可能解决?

回答

5

删除intBinaryHeap b(int n);b.insert(int ch);,你很好去。

当你调用一个函数时,你不应该指定你调用它的变量的数据类型。

+0

感谢,它的工作 –

1

尝试修改此

b.insert(int ch); 

这样:

b.insert(ch);