hey all,
first i should say ive been using java for most of my programming, but now we have to make some kind of a priority heap in C++ and stl for school. I managed to solve all the compile errors but one ..
I think it has a quite simple solution but really cant find it
compiler likes initializing of PQueue and test, but throws error on the DMap initialization :
a
any ideas?
tnx
first i should say ive been using java for most of my programming, but now we have to make some kind of a priority heap in C++ and stl for school. I managed to solve all the compile errors but one ..
I think it has a quite simple solution but really cant find it
Code:
template <class P, class D> // P = priority class, D = data class
class PHeap {
private:
priority_queue<P> PQueue; // priority queue with our priorities, not containing the data
map<P, list<D> > DMap; // Map with a list of data for every key
public:
PHeap();
~PHeap();
bool isEmpty();
D getRoot();
void removeRoot();
void insert(P,D);
};
template <class P, class D>
PHeap<P,D>::PHeap(){
PQueue = *( new priority_queue<P>() );
map<P,D> test;
DMap = *(new map<P,D>() ) ;
}
...
compiler likes initializing of PQueue and test, but throws error on the DMap initialization :
a
Code:
PHeap.h: In constructor `PHeap<P, D>::PHeap() [with P = int, D = int]':
PHTest.cpp:5: instantiated from here
PHeap.h:43: error: no match for 'operator=' in 'this->PHeap<int, int>::dDMap =
(operator new(unsigned int)(12), ((true, (<anonymous>->std::map<_Key, _Tp,
_Compare, _Alloc>::map() [with _Key = int, _Tp = int, _Compare =
std::less<int>, _Alloc = std::allocator<std::pair<const int, int> >](),
(<anonymous> <unknown operator> false))), <anonymous>))'
/usr/include/g++/bits/stl_map.h:213: error: candidates are: std::map<_Key, _Tp,
_Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(const
std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = int, _Tp =
std::list<int, std::allocator<int> >, _Compare = std::less<int>, _Alloc =
std::allocator<std::pair<const int, std::list<int, std::allocator<int> > >
>]
any ideas?
tnx