k****i 发帖数: 128 | | h**o 发帖数: 548 | 2 谁考你了?
template
class Node{ //used by List
Node(T data, Node* next):_data(data), _next(next){}
T _data;
Node* _next;
friend class List; //only friend can call private
friend class ListIterator;
};
template
class List{
List(Node* head=NULL, Node* tail=NULL);
List(const List& orig);
List& operator=(const List& orig);
push_front();push_end();pop_front();pop_end();
//the following are used for iterator:
typedef ListIterator iterator;
iterator begin(){return iterator(_head); }
iterator end(){return iterator(); }
private:
Node* _head, *_tail;
};
template
class ListIterator{
Node* _cur;
public:
ListIterator(Node* cur= NULL): _cur(cur){}
ListIterator(const ListIterator& orig){_cur = orig._cur;}
ListIterator& operator=(const ListIterator& orig){_cur = orig_cur;
return *this;}
bool operator==(const ListIterator& orig){return _cur == orig._cur;}
ListIterator& operator++(){_cur = _cur->_next; return *this; }
ListIterator operator++(int i){ ListIterator a(*this); _cur = _cur->_
next; return a; }
const T operator*() const {return _cur->_data;}
}; | h******6 发帖数: 2697 | 3 我当年面google的intern也被一个烙印问过 当年不会 到现在也还是不会 因为我就不
熟悉c++
看来这题考的还挺频繁?高频题吗? | k****i 发帖数: 128 | 4 寄信人: deliver (自动发信系统)
标 题: 本站转帐通知单
发信站: BBS 未名空间站 (Tue Jan 28 18:29:46 2014)
来 源: mitbbs.com
kazumi,您好:
您转给 hero,现金(伪币):10,收取手续费:0.1
站务 |
|