65,187
社区成员




#include <iostream>
#include <cstring> // string型数据
#include <string>
#include <stdlib.h> // exit(1)
#include "genealogyNode.h"
using std::string;
// 第一个构造函数,仅带双亲结点,左右孩子,默认值为NULL
genealogyNode::genealogyNode(genealogyNode * p = NULL, genealogyNode * l = NULL, genealogyNode * r = NULL)
: parent(p), leftChild(l), rightChild(r){}
// 第二个构造函数,支持全部数据成员的输入
genealogyNode::genealogyNode( string n, string s, string dD, string bD, string bT, string j, string re,
genealogyNode * p = NULL, genealogyNode * l = NULL, genealogyNode * r = NULL)
: parent(p), leftChild(l), rightChild(r), remark(r), job(j), name(n)
{
sex = translateInSex(s);
dieDate = translateInDate(dD);
bornDate = translateInDate(bD);
booldType = translateInBooldType(bT);
// genealogyNode.h -- 家谱结点类
#ifndef GENEALOGYNODE_H
#define GENEALOGYNODE_H
class string;
using std::string;
class genealogyNode
{
public:
string name; // 名字
char sex; // 姓别, m代表男姓,f代表女姓
long dieDate; // 死亡日期,[5...8][1...9999][1..12][1...31]
long bornDate; // 出生日期,[5...8][1...9999][1..12][1...31]
char booldType; // 血型,O型:o, AB型:c, A型a, B型b
string job; // 工作
string remark; // 备注,当为空时,用[...]表示
genealogyNode * parent;
genealogyNode * leftChild;
genealogyNode * rightChild;
public:
// 第一个构造函数,仅带双亲结点,左右孩子,默认值为NULL
genealogyNode(genealogyNode *, genealogyNode *, genealogyNode *);
// 第二个构造函数,支持全部数据成员的输入
genealogyNode(string, string, string, string, string, string, string, genealogyNode *, genealogyNode *, genealogyNode *);
char translateInSex(string); // 将string类型的sex数据转为char型存储
long translateInDate(string); // 将string类型的Date数据转为long型存储
char translateInBooldType(string); // 将string类型的booldType数据转为int型存储
long transInDateHelp(char); // 作为数据转换的辅助函数
string transOutDateHelp(long);
string translateOutSex(); // 将类中的数据成员sex的数据转出为string类型
string translateOutDate(char type); // 将类中的数据成员Date的数据转出为string类型
string translateOutBooldType(); // 将类中的数据成员booldType数据转出为string类型
};
#endif // genealogyNode.h
genealogyNode::genealogyNode( string n, string s, string dD, string bD, string bT, string j, string re,
genealogyNode * p = NULL, genealogyNode * l = NULL, genealogyNode * r = NULL)
: parent(p), leftChild(l), rightChild(r), /*remark(r), */job(j), name(n)
{
}