#ifndef XX_h
#define XX_h
// SYSTEM INCLUDES
//
// PROJECT INCLUDES
//
// FORWARD REFERENCES
//
namespace NN
{
/**
* A detailed description of the class.
**
@brief A short description of the class
* @author Name of the author
* @version version
*/
class XX
{
public:
/// @name Lifecyle
//@{
// LIFECYCLE
/**
* Default constructor.
*/
XX();
/**
* Copy constructor.
**
@param from The value to copy to this object.
*/
XX(const XX &from);
/**
* Destructor.
*/
~XX();
//@}
// OPERATORS
/**
* Assignment operator.
**
@param from the value to assign to this object.
**
@return A reference to this object.
XX &operator=(XX &from);
// OPERATIONS
/// @name Accessors
//@{
// ACCESS
//@}
/// @name Inquiries
//@{
// INQUIRY
//@}
protected:
/**
* An odd static method
*/
static void oddStaticMethod();
/**
* An odd inline method
*/
void oddInlineMethod();
/**
* An odd static and inline method
*/
static void oddStaticInlineMethod();
private:
// MEMBER VARIABLES
static int mInstances;
};
// INLINE METHODS
#include
}
// EXTERNAL REFERENCES
//
#endif // XX_h
5. Class Implementation
A common class implementation layout is critical from a code comprehension point of view. Static
member variables initialization and static methods must come first because the static keyword is
forbidden in class implementation.
Following is the template that should be used to organize each class implementation.
Example 5.8: Class Implementation Template
// STATIC MEMBER VARIABLES INITIALIZATION
int XX::mInstances = 0;
// STATIC METHODS
void XX::oddStaticMethod()
{
// implementation
}
// NON STATIC METHODS
XX::XX()
{
instances++;
// implementation
}
XX::XX(const XX &from)
{
instances++;
// implementation
}
XX::~XX()
{
instances−−;
// implementation
}
XX &XX::operator=(XX &from)
{
// implementation
}
6. Class Inline Methods Implementation
A common class inline methods implementation layout is critical from a code comprehension point
of view. Static methods must come first because the static keyword is forbidden in inline methods
implementation.
Following is the template that should be used to organize each class inline methods
implementation.
Example 5.9: Class Inline Methods Implementation Template
#ifndef XX_inline_h
#define XX_inline_h
// STATIC METHODS
inline void XX::oddStaticInlineMethod()
{
// implementation
}
// NON STATIC METHODS
inline void XX::oddInlineMethod()
{
// implementation
}
#endif // XX_inline_h
ไม่มีความคิดเห็น:
แสดงความคิดเห็น