WWC snapshot of http://www.alw.nih.gov/Docs/NIHCL/nihcl_50.html taken on Sat Jun 10 19:14:04 1995

Go to the previous, next section.

Template_h--Template Class Header File

SYNOPSIS

`Template_h'

RELATED FILES

`Template_c'

DESCRIPTION

The file `Template_h' provides a useful start when writing the header file for a new NIH Library class. If you're writing a new class named MyClass derived from the NIH Library class BaseClass, for example, a good way to begin is to copy `Template_h' to `MyClass.h', then use your favorite text editor to change all occurrences of the strings "THIS_CLASS" to "MyClass" and "BASE_CLASS" to "BaseClass". You can then add the declarations for the additional member functions you wish to define.

#ifndef THIS_CLASS_H
#define THIS_CLASS_H

/* Template.h -- example header file for an NIH Library class
    ...
*/

// Define "MI" if this class uses multiple inheritance:
//#ifndef MI
//#define MI
//#endif

#include <nihcl/BASE_CLASS.h>
// #include .h files for other classes used
// Insert only class declarations for classes accessed
// by pointer and reference ONLY

// If BASE_CLASS is Object:
// class THIS_CLASS: public VIRTUAL Object {

class THIS_CLASS: public BASE_CLASS {
    DECLARE_MEMBERS(THIS_CLASS);
// member variables here
protected:      // storer() functions for object I/O
    virtual void storer(OIOofd&) const;
    virtual void storer(OIOout&) const;
public:
    bool operator==(const THIS_CLASS&) const;
    bool operator!=(const THIS_CLASS& a) const
        { return !(*this==a); }
    virtual int compare(const Object&) const;
    virtual Object* copy() const;       // shallowCopy() default
                                        // if not defined
    virtual void deepenShallowCopy();
    virtual unsigned hash() const;
    virtual bool isEqual(const Object&) const;
    virtual void printOn(ostream& strm =cout) const;
    virtual const Class* species() const;
};

#endif

Go to the previous, next section.