I am working on Michael J Laszlo's Book 'Computation Geometry and Computer Graphics in C++' . The following is a template class prototype:
template <class T> class ListNode : public Node {
T _val;
ListNode (T val);
friend class List<T>;
};
template <class T> ListNode <T>::ListNode(T val)
{_val=val;};
template <class T> class List{
private:
ListNode <T> *header;
ListNode <T> *win;
int _length;
public:
List(void);
~List(void);
T insert(T);
T append(T);
List * append(List*);
T prepend(T);
T remove(void);
void val(T); // overloaded function!
T val(void);// overloaded function!
T next(void);
T prev(void);
T first(void);
T last(void);
int length(void);
bool isFirst(void);
bool isLast(void);
bool isHead(void);
};
Now look at the way he defines the List constructor:
// constructors and destructors
template <class T> list<T>:: List(void): _length(0)
{
header =new ListNode<T>(NULL);
win=header;
}
My Question:
What is up with the assigning a default length outside the {...}
and the rest inside? Is there some sort of logical reasoning behind this?
Because for example before this, he pretty much declared everything outside the {...}
and I assumed that was just his style