client.cpp

来自「数据结构 ssd5 ex1」· C++ 代码 · 共 90 行

CPP
90
字号
#include "Client.h"
//Default constructor Initializes the private data members to default values 
Client::Client(void)
{
	fname = "";//frist name
    lname = "";//last name
    email = "";//email of client
    passwd = "";//password of client
}

//copy constructor
Client::Client(Client const &c)
{
	this->fname=c.fname;
	this->lname=c.lname;
	this->email=c.email;
	this->passwd=c.passwd;
}
//constructor  set private data members   
Client::Client (string &fname, string &lname, string &email, string &passwd)
{
	this->fname=fname;
	this->lname=lname;
	this->email=email;
	this->passwd=passwd;
}

//set the private data members 
void Client::setFname(const string& c)
{
	this->fname=c;
}

void Client::setLname(const string& c)
{
	this->lname=c;	
}

void Client::setEmail(const string& c)
{
	this->email=c;
}

void Client::setPasswd(const string& c)
{
	this->passwd=c;
}
//return the private data members 
string Client::getFname () const
{
	return fname;
}
string Client::getLname () const
{
	return lname;
}
string Client::getEmail () const
{
	return email;
}
string Client::getPasswd () const
{
	return passwd;
}
//Returns true if the invoking object's password matches the password given in the parameter, false if otherwise
bool Client::verifyPasswd(string passwd)
{
	if(this->passwd==passwd)
		return 1;
	else
		return 0;
}
//over loading operator>> reads a Client object from an input stream
istream &operator>>(istream &is, Client &c)
{
	string t;
	is >> t;
	c.setFname(t);

	is >> t;
	c.setLname(t);

	is >> t;
	c.setEmail(t);

	is >> t;
	c.setPasswd(t);

	return is;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?