Click here to Skip to main content
15,891,713 members
Articles / Programming Languages / C++

Address Book

Rate me:
Please Sign up or sign in to vote.
4.48/5 (21 votes)
6 Aug 2000CPOL3 min read 286K   5.5K   93  
Address Book application
/* ------------------------ Person.cpp ------------------------------

  CPerson is a very simple class with holds all the data relating
  to a person.
  

  -------------------------------------------------------------------*/
#include <stdafx.h>
#include "person.h"

IMPLEMENT_SERIAL( CPerson, CObject, 0 )

CPerson::CPerson()
{
	Empty();
}

// Serialize is overloaded to take care of saving and loading the data.
void CPerson::Serialize( CArchive& archive )
{
    // call base class function first
    // base class is CObject in this case
    CObject::Serialize( archive );

    if( archive.IsStoring() )
        archive << m_strFirstName 
	            << m_strLastName
				<< m_strMiddleName
				<< m_strName
				<< m_strNickName
				<< m_strEMail
				<< m_strHomeStreet
				<< m_strHomeCity
				<< m_strHomePostalCode
				<< m_strHomeState
				<< m_strHomeCountry
				<< m_strHomePhone
				<< m_strHomeFax
				<< m_strCarPhone
				<< m_strPersonalWebPage
				<< m_strBusinessStreet
				<< m_strBusinessCity
				<< m_strBusinessPostalCode
				<< m_strBusinessState
				<< m_strBusinessCountry
				<< m_strBusinessWebPage
				<< m_strBusinessPhone
				<< m_strBusinessFax
				<< m_strPager
				<< m_strCompany
				<< m_strJobTitle
				<< m_strDepartment
				<< m_strOfficeLocation
				<< m_strNotes;
	
    else
        archive >> m_strFirstName 
	            >> m_strLastName
				>> m_strMiddleName
				>> m_strName
				>> m_strNickName
				>> m_strEMail
				>> m_strHomeStreet
				>> m_strHomeCity
				>> m_strHomePostalCode
				>> m_strHomeState
				>> m_strHomeCountry
				>> m_strHomePhone
				>> m_strHomeFax
				>> m_strCarPhone
				>> m_strPersonalWebPage
				>> m_strBusinessStreet
				>> m_strBusinessCity
				>> m_strBusinessPostalCode
				>> m_strBusinessState
				>> m_strBusinessCountry
				>> m_strBusinessWebPage
				>> m_strBusinessPhone
				>> m_strBusinessFax
				>> m_strPager
				>> m_strCompany
				>> m_strJobTitle
				>> m_strDepartment
				>> m_strOfficeLocation
				>> m_strNotes;
}

CPerson & CPerson::operator =(CPerson &person)
{
         m_strFirstName =         person.m_strFirstName; 
	     m_strLastName =          person.m_strLastName;
		 m_strMiddleName =        person.m_strMiddleName;
		 m_strName =              person.m_strName;
		 m_strNickName =          person.m_strNickName;
		 m_strEMail =             person.m_strEMail;
		 m_strHomeStreet =        person.m_strHomeStreet;
		 m_strHomeCity=           person.m_strHomeCity;
		 m_strHomePostalCode=     person.m_strHomePostalCode;
		 m_strHomeState=          person.m_strHomeState;
		 m_strHomeCountry=        person.m_strHomeCountry;
		 m_strHomePhone=          person.m_strHomePhone;
		 m_strHomeFax=            person.m_strHomeFax;
		 m_strCarPhone=           person.m_strCarPhone;
		 m_strPersonalWebPage=    person.m_strPersonalWebPage;
		 m_strBusinessStreet=     person.m_strBusinessStreet;
		 m_strBusinessCity=       person.m_strBusinessCity;
		 m_strBusinessPostalCode= person.m_strBusinessPostalCode;
		 m_strBusinessState=      person.m_strBusinessState;
		 m_strBusinessCountry=    person.m_strBusinessCountry;
		 m_strBusinessWebPage=    person.m_strBusinessWebPage;
		 m_strBusinessPhone=      person.m_strBusinessPhone;
		 m_strBusinessFax=        person.m_strBusinessFax;
		 m_strPager=              person.m_strPager;
		 m_strCompany=            person.m_strCompany;
		 m_strJobTitle=           person.m_strJobTitle;
		 m_strDepartment=         person.m_strDepartment;
		 m_strOfficeLocation=     person.m_strOfficeLocation;
		 m_strNotes=              person.m_strNotes;
		 return *this;
}

void CPerson::Empty()
{
	m_strFirstName= m_strLastName= m_strMiddleName=
    m_strName= m_strNickName= m_strEMail=m_strHomeStreet=
    m_strHomeCity= m_strHomePostalCode=m_strHomeState=
	m_strHomeCountry=m_strHomePhone=m_strHomeFax=
	m_strCarPhone=m_strPersonalWebPage=m_strBusinessStreet=
	m_strBusinessCity=m_strBusinessPostalCode=m_strBusinessState=
	m_strBusinessCountry=m_strBusinessWebPage=m_strBusinessPhone=
	m_strBusinessFax=m_strPager=m_strCompany= m_strJobTitle=
	m_strDepartment=m_strOfficeLocation=m_strNotes="";
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions