c++模板类下标运算符重载

时间:2022-10-19 17:34:18
template<class T>
class Heap
{
public:
    void pop();
    void push(T);
    int top();
    Heap(int s);
    int size();
    void MaxHeap(vector<T> &arr, const int &size, int element);
    void HeapSort(vector<T>&arr, int size);
    const T& operator[](int i);
private:
    vector <T> heap;
    int Size;
};
const T&Heap<T>::operator[](int i)
{
    return heap[i];
}