输入方式确定,输出结果的格式也确定。首先,将结果中不变的东西提取出来,如类的格式,制成模板:
class ClassName
{
ClassName();
ClassName(ConstructorParameterList);
ClassName(const ClassName &rhs);
ClassName& operator = (const ClassName &rhs);
~ClassName();
public: // private:
VariableList
};
ClassName::ClassName()
: DefaultInitializationList
{
}
ClassName::ClassName(ConstructorParameterList)
: ParameterInitializationList
{
}
ClassName::ClassName(const ClassName &rhs)
{
*this = rhs;
}
ClassName& ClassName::operator = (const ClassName &rhs)
{
if (&rhs != this)
{
AssignmentList
}
return *this;
}
ClassName::~ClassName()
{
}