I have the following classes:
template <class S, class T>
class Pair {
protected:
S data1;
T data2;
public:
...
}
template <class S, class T>
class Node: public Pair<const KeyType, DataType> {
private:
Node<const S, T>* next;
public:
//C'tor
Node(const KeyType& sKey, const DataType& sData) :
data1(sKey), data2(sData), next(NULL) {
}
//Copy C'tor
Node(const Node<KeyType, DataType>& sNode):
data1(sNode.getData1()), data2(sNode.getData2()), next(NULL) {
}
...
};
But for some reason I can't manage to work with data1 and data2 whom Node inherited from Pair. I get the following errors:
./map.h:24:5: error: use of undeclared identifier 'data1'
data1 = sKey;
^
./map.h:25:5: error: use of undeclared identifier 'data2'
data2 = sData;
^
./map.h:30:4: error: member initializer 'data1' does not name a non-static data member or base class
data1(sNode.getData1()), data2(sNode.getData2()), next(NULL) {
^~~~~~~~~~~~~~~~~~~~~~~
./map.h:30:29: error: member initializer 'data2' does not name a non-static data member or base class
data1(sNode.getData1()), data2(sNode.getData2()), next(NULL) {
^~~~~~~~~~~~~~~~~~~~~~~
What I'm doing wrong?
*This is part of my HW assignment so I can't use pair from the STL.