Well, you defined your constructor/destructor as private in both classes. Have you tried giving them public access?
You declared here
class Tester
{
private:
friend class test;
Tester(){};
~Tester(){};
};
that class test is a friend of Tester. So the class test shall be defined in the same scope as class Tester. However you did not give its definition.
class test is not the same as Test::test.
Last edited on
Hmm, in my real file it is okay. (Slow day, had fun with my linked list)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
template <typename T>
class LinkedList
{
//friend class Iterator<T>;
public:
typedef Iterator<T> iterator;
iterator begin(void) { return head; }
iterator end(void) { return NULL; }
private:
// Member Variables
Node<T>* head;
Node<T>* tail;
unsigned size;
// Member Functions
void deleteList(void);
public:
// Construct/Destruct
LinkedList(void) : head(NULL), tail(NULL), size(0) {}
~LinkedList(void) { deleteList(); }
// Member Functions
bool empty(void) { return size == 0; }
unsigned sizeOf(void) { return size; }
void push_back(const T& data);
void insert(const T& data, unsigned pos);
void insert(const T& data, Iterator<T>& iter);
void remove(unsigned pos);
void remove(Iterator<T>& iter);
};
template <typename T>
class Iterator
{
//Friends
friend class LinkedList<T>;
private:
// Member Variables
Node<T>* nodePtr;
// Construct/Destruct
Iterator(Node<T>* nodePtr) : nodePtr(nodePtr) {}
public:
Iterator(void) : nodePtr(NULL) {}
~Iterator(void) {}
void operator=(const Node<T>* nodePtr);
void operator++(void);
void operator--(void);
T& operator*(void);
bool operator==(const Iterator<T>& iter);
bool operator!=(const Iterator<T>& iter);
};
|
You may see that my last post didn't really solve it, and that I've reverted back to my public constructor (why spend so much time on one line?).
As a side, I've noticed my "--" and "++" overloads are only for the prefixed version (++iter;), how would I make a postfix version?
Last edited on