(2). 登陆参数类实现 (fields.cpp)源码:
    
#include "include/fields.h"
#include <iostream>
#include <cstring>
 
/*构造函数*/
Fields::Fields(char *usr,char *pass,unsigned int pt,char *server,char *defaultDb,char *socket,unsigned int f)
{
        this->setUser(usr);
        this->setPass(pass);
        this->setServer(server);
        this->setPort(pt);
        this->setDefaultDb(defaultDb);
        this->setSocket(socket);
        this->setFlag(f);
}
/*复制构造函数*/
Fields::Fields(const Fields & f)
{
        this->setUser(f.username);
        this->setPass(f.password);
        this->setServer(f.server);
        this->setPort(f.port);
        this->setDefaultDb(f.defaultDb);
        this->setSocket(f.unix_socket);
        this->setFlag(f.flag);
}
/*析构函数*/
Fields::~Fields()
{
        delete[]username;
        delete[]password;
        delete[]server;
        delete[]defaultDb;
        delete[]unix_socket;
}

/*重载赋值操作符*/
Fields & Fields::operator=(const Fields &f)
{
        if( this == &f )
        {
                return *this;
        }
        else
        {
                delete[]username;
                delete[]password;
                delete[]server;
                delete[]defaultDb;
                delete[]unix_socket;
                this->setUser(f.username);
                this->setPass(f.password);
                this->setServer(f.server);
                this->setPort(f.port);
                this->setDefaultDb(f.defaultDb);
                this->setSocket(f.unix_socket);
                this->setFlag(f.flag);
                return *this;
        }
}
/*设置用户*/
bool Fields::setUser(char *user)
{
        this->username=new char[strlen(user)+1];
        strcpy(this->username,user);
        return true;
}
bool Fields::setPass(char *pass)
{
        this->password=new char[strlen(pass)+1];
        strcpy(this->password,pass);
        return true;
}
 
bool Fields::setServer(char *server)
{
        this->server=new char[strlen(server)+1];
        strcpy(this->server,server);
        return true;
}
bool Fields::setDefaultDb(char *db)
{
        this->defaultDb=new char[strlen(db)+1];
        strcpy(this->defaultDb,db);
        return true;
}
bool Fields::setPort(unsigned int pt)
{
        this->port=pt;
        return true;
}
bool Fields::setSocket(char *socket)
{
        this->unix_socket=socket;
        return true;
}
bool Fields::setFlag(unsigned int flag)
{
        this->flag=flag;
        return true;
}

/*获取*/
char * Fields::getUser()const
{
        return this->username;
}
char * Fields::getPass()const
{
        return this->password;
}
char * Fields::getServer()const
{
        return this->server;
}
char * Fields::getDefaultDb()const
{
        return this->defaultDb;
}
unsigned int  Fields::getPort()const
{
        return this->port;
}
char * Fields::getSocket()const
{
        return this->unix_socket;
}
unsigned int Fields::getFlag()const
{
        return this->flag;
}

/*友元<<*/
ostream & operator<<(ostream &os,const Fields &f)
{
        os<<"用户名:"<<f.username<<endl;
        os<<"密码:"<<f.password<<endl;
        os<<"服务器:"<<f.server<<endl;
        os<<"默认数据库:"<<f.defaultDb<<endl;
        os<<"端口号:"<<f.port<<endl;
        os<<"Socket设置:"<<(f.unix_socket? f.unix_socket:"空")<<endl;
        os<<"标志:"<<f.flag<<endl;
        return os;
}