22)Provide other member function as needed. Overload the operator<<and operator>> to read and write the statistic variable. The operator <<will print both the average and standard deviation to an output stream. The operator >> will read on element from the input stream.
Code:
//TEMPLET CLASS#ifndef_LIST_#define_LIST_#include<iostream>template<typename TYPE>class Node{template<typename T> friend class List;public:Node() {}~ Node() {}Node *prev(){return PREV;}Node *next(){return NEXT;}Node &set(Type d){data=d;return*this;}Node get() {return data;}Privet:Node *Next;Node *prev;TYPE data;};template <typename TYPE>Class List{friend std::ostream &operator<<(std::ostream& out,List<TYPE>)&List){cout<<"(";for(Node<type)*ptr=list.head;ptr!=NULL; ptr=ptr->next()){out<<ptr->get();if (ptr->next () !Null)out<<",";}out<<")";return out;}puplic:List(){head = tail=NULL;count=0;}//empty list~list(){}Node<TYPE>*first(){return head;}Node<TYPE>*insertLast(TYPE d){Node<TYPE>*n=new Node<TYPE>;N->data=d;//using a copy constructorif(tail==NULL){//empty listhead=tail=n;n->NEXT =n->PREV=NULL;}else{n->NEXT=NULL;n->PREV=tail;tail->NEXT=n;tail=n;}++count;return n;}TYPE removLast() {TYPE d; //need to set a defult valueif (tail==NULL)return d;//default return value for empty listd=tail->data;if (tail!=head){tail=tail->PREV;delet tail->NEXT;tail->NEXT=NULL;}else{delet tail;tail=head=NULL;}--count;return d;}Node<TYPE>*insertFirst(TYPE d){Node<TYPE>*n=new Node<TYPE>;n->data=d;if (head==NULL){//empty Listhead=tail=n;n->NEXT = N->prev=NULL;}else{n->PREV=NULL;n->NEXT =head;head->PREV=n;head=n;}++count;return n;}TYPE removeFirst(){TYPE d;//need to set a default valueif (head==NULL)return d; //default return value for empty listd=head->data;if (head!=tail){head=head->PREV;delet head ->PREV;head->PREV=NULL;}else{delete head;head=tail=NULL;}--count;return d;}Node<TYPE>*insertAt(int i,TYPE d){Node<TYPE>*n=NULL;IF(0<=i && i<=xount){n=new Node<TYPE>;n->data=d;cout<<"cout="<<cout<<endl;if (i==0)insertFirst(d);else if (i==count)insertLast(d);else {Node<TYPLE)*ptr=head;for(int cnt=0;cnt<i-1;++cnt)ptr=ptr->NEXT;n->PREV=ptr;n->NEXT =ptr->NEXT;n->PREV->NEXT=n;n->NEXT->PREV=n;++count;}}return n;}TYPE removeAt(int i){TYPE d;return d;}Node<TYPE>*Push(TYPE d){return insertlast();}Type pop(){return removeLast();}int size(){return count==0;}bool isEmpty(){return count==0;TYPE peek(){return tail->data;}private:Node<TYPE>*head;Node<TYPE>*tail;int count;};#endif
I tried many times but I couldn't any one want help ?
