template <class T>
class List
{
class Node
{
public:
Node()
{
next = 0;
data = 0;
}
Node* next;
T data;
};
Node* head = new Node;
Node* tail = new Node;
int size = 0;
public:
class Iterator
{
Node* curr;
friend class List<T>;
public:
Iterator()
{
curr = nullptr;
}
friend void fun()
{
cout << "helloworld" << endl;
}
Iterator begin()
{
Iterator it(head->next);
return it;
}
};
};
created two more class of blocks and programs, programs contained a list of blocks. Implemented iterators for ease of use, But am not able to access its public and private members through list class.
int main()
{
List<int> l1;
List<int>::Iterator it;
it = l1.begin();
fun();//iterator befriending neither class nor function
}
Error was: class List has no member begin E0135 begin: is not a member of class list C2039 On vs22