2013-06-25 39 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);