Here is an example of a header file Note that the class definition has a block of text within asterisks, that described briefly what the class does. Then, we break up the member function declarations into categories, and have a brief comment describing each category. #ifndef _included_Grid1_h #define _included_Grid1_h /**************************************************************** * Grid1.h * * * * Class Grid1 implements an 1-dimensional lparx grid. * * The elements of the grid are given by ``tTYPE''. * * * * Author: Scott Kohn (skohn-at-cs.ucsd.edu) * * Revisisions: Stephen Fink * * rewrote for KeLP * *****************************************************************/ #ifndef NULL #define NULL ((void *) 0) #endif /**************************************************************** * class Grid1 * * * * Declare the Grid1 class for an object of type ``tTYPE''. * * This class implements a basic array class. * * * * Implementor's note: I would prefer to derive Grid from * * XObject, and allow const access to the base XObject class. * * i.e, operator const XObject1& () const {return (*this);}* * Unfortunately, some compilers don't allow this kind of trick. * *****************************************************************/ template class Grid1 { Array1 _data; XObject1 _xobject; /* Define the constructor and member functions for class Grid1 */ private: Grid1(const Grid1&); void operator = (const Grid1&); public: Grid1() {} Grid1(const int processor): _xobject(processor) {} Grid1(const Region1& region, const int processor); Grid1(const int i, const int processor); ~Grid1(); /* Define the functions for indexing the Grid object */ const Point1& lower() const { return _xobject.lower(); } const Point1& upper() const { return _xobject.upper(); } const Point1 extents() const { return _xobject.extents(); } int lower(const int i) const {return _xobject.lower(i); } int upper(const int i) const { return _xobject.upper(i); } int extents(const int i) const { return _xobject.extents(i); } tTYPE& operator () (const Point1& p) { return _data(p); } const tTYPE *ptr(const int i) const { return _data.ptr(i); } const tTYPE *ptr(const Point1& p) const { return _data.ptr(p); } const tTYPE *data() const { return _data.data(); } tTYPE *data() { return _data.data(); } const Region1& region() const {return _xobject;} operator const XObject1& () const {return (_xobject); } /* member functions to modify Grids */ void resize(const Region1& R); int owner() const {return _xobject.owner();} void setowner(const int p) {_xobject.setowner(p); } /* member functions to move data from/to Grids */ void CopyRegion(const Region1& to, const Grid1& src, const Region1& from); void UnPackRegion(tTYPE *buffer, const Region1& to); }; #endif