I have a linked List
template<class T>
class Node<T>
{
typedef T elementType;
typedef Node<T>* position;
elementType _element;
position _next;
};
template <class T>
class LinkedList
{
public:
typedef Node<T>::position position;
typedef Node<T>::elementType elementType;
//operatori
bool empty() constprevious;
unsigned int size() constprevious; //convertire il tipo ritornato in unsigned int!! per tutte classi e metodi rilevanti **LEO**
elementType read(const position) constprevious;
void write(const position p, const elementType)previous;
void insert(const elementType)previous;
void insert(const position, const elementType)previous;
void delete(position)previous;
position first() constprevious;
position last() constprevious;
position next(position) constprevious;
position previous(position) constprevious;
void deleteAll();
private:
position _first;
position _last;
int _numElements;
};
template<class T>
istream &operator>> (istream &input, LinkedList<T> &linkedList )
{
//operator Code
return is;
}
**Please note:above code might not compile as I got it by modifing my original code, which is much much longer. Anyway, since I just need an indication of how to proceed, that shoud be ok.
I want to overload operator>> in a way that in my code I can write something like
#include <cstdlib>
#include <iostream>
using namespace std;
//#include "LinkedList.h"
int main(int argc, char *argv[])
{
LinkedList linkedList;
cin>>linkedList; //<-- operator>> call.
system("PAUSE");
return EXIT_SUCCESS;
}
However, how do I implement the >> operator, so that I make it indipendent from stream type (file, keyboard)?
I have not been able to find anything about this on google.