home > resources > c++ coding standard > online version

Class Layout

A common class layout is critical from a code comprehension point of view and for automatically generating documentation. C++ programmers, through a new set of tools, can enjoy the same level generated documentation Java programmers take for granted.

Following is the template that should be used to organize each class declaration.

Example 4-2. Class Layout Template

/**      
 * A detailed description of the class.
 * 
 * @short A short description of the class
 * @author Name of the author
 * @version version
 * @since version
 * @see something
 */

#ifndef XX_h
#define XX_h

// SYSTEM INCLUDES
//

// PROJECT INCLUDES
//

// LOCAL INCLUDES
//

// FORWARD REFERENCES
//


class XX
{
public:
// LIFECYCLE

    /**
     * Default constructor.
     */
    XX(void);
    
    /**
     * Copy constructor.
     *
     * @param from The value to copy to this object.
     */
    XX(const XX& from);
    
    /**
     * Destructor.
     */
    ~XX(void);

// OPERATORS

    /**
     * Assignment operator.
     *
     * @param from the value to assign to this object.
     *
     * @return A reference to this object.
     */
    XX& operator=(XX& from);  

// OPERATIONS                       
// ACCESS
// INQUIRY

protected:
private:

// MEMBER VARIABLES

};

// INLINE METHODS
//

// EXTERNAL REFERENCES
//

#endif  // XX_h