Generic class

Help me brother .
i have made a class like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
template<typename t1, typename t2>
class Set{
	
private:
	t1 key;
	t2 value;
	
public:	
	Set(t1 k, t2 val);
	t1 getKey();
	t2 getValue();
	void setKey(t1 k);
	void setValue(t2 val);
	
};



Now i am trying to declare a vector of type Set<t1, t2>
like
1
2
vector<Set<t1, t2>> heap;



this is the class i am declaring vector of type Set<t1, t2>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
template<typename t1, typename t2>
class MaxHeap {
public:
    MaxHeap(Set <t1, t2>ar[], int length);
    MaxHeap();
    ~MaxHeap();
    void add(Set<t1, t2> element);
    Set<t1, t2> extractMax();
    Set<t1,t2> maximum();
    void print();
    void increaseKey(t1 k, t2 inc);
    int size() { return heap.size(); }
private:
    int left(int parent);
    int right(int parent);
    int parent(int child);
    void heapifyup(int index);
    void heapifydown(int index);
    vector<Set<t1, t2>> heap;
};


but this gives an error at the declaration of vector. please help me.
What is the error?

Did you #include the proper header for that class?
yep i did
 
vector<Set<t1,t2>> set; // here is the error 


Error is
 
template argument is invalid
What is the complete error, all of them? There is important information embedded within these error messages to aid in locating and fixing the problems.

Also please show the complete implementation for that template class, including the #include declarations.


Last edited on
Topic archived. No new replies allowed.