⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 person.cpp

📁 用C++写的一个简单学籍管理系统
💻 CPP
字号:
#include "person.h"

Person::Person( const char *name,const int id,const Sex sex)
{
	Person::name = name;
	Person::id = id;
	Person::sex = sex;
}
Person::Person( const string name,const int id /* =-1 */,const Sex sex)
{
	Person::name = name;
	Person::id = id;
	Person::sex = sex;
}
Person::Person( const Person & p)
{
	name  = p.name;
	id        = p.id;
	sex      = p.sex;
}

Person::~Person()
{
	id = -1;
	name.clear(); //需要析构吗?
}

Person & Person::operator = (const Person & p)
{
	name = p.name;
	id       = p.id;
	sex     = p.sex;
	return *this;
}

const string Person::getName()const
{
	return name;
}

const int Person::getId()const
{
	return id;
}

const Sex Person::getSex()const
{
	return sex;
}
void Person::setName( char * name)
{
	Person::name = name;
}

void Person::setName( string name)
{
	Person::name = name;
}

void Person::setId( int id)
{
	Person::id = id;
}
void Person::setSex(Sex sex)
{
	Person::sex = sex;
}
istream & operator >>(istream & is,Sex &sex )
{
	string  tpSex ;
	is>>tpSex;
	if (tpSex=="M"||tpSex == "m" )
	{
		sex = MALE;
	}
	else if(tpSex == "F"||tpSex== "f" )
	{
		sex = FEMALE;
	}
	return is;
}

⌨️ 快捷键说明

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