home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
TUTORIAL
/
ICLCC
/
TUTOR5
/
SOLUTION
/
KPERSON.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-07
|
3KB
|
55 lines
/******************************************************************************/
/* */
/* COPYRIGHT: */
/* ---------- */
/* Copyright (C) International Business Machines Corp., 1991,1992. */
/* */
/* DISCLAIMER OF WARRANTIES: */
/* ------------------------- */
/* The following [enclosed] code is sample code created by IBM */
/* Corporation. This sample code is not part of any standard IBM product */
/* and is provided to you solely for the purpose of assisting you in the */
/* development of your applications. The code is provided "AS IS", */
/* without warranty of any kind. IBM shall not be liable for any damages */
/* arising out of your use of the sample code, even if they have been */
/* advised of the possibility of such damages. */
/* */
/******************************************************************************/
#include <tstring.h>
#include <iglobals.h>
class Person {
String name; // the key
String telephoneNumber;
public:
Person(char* n, char* tel) : name(n), telephoneNumber(tel) { }
Person(Person const & person) : name(person.name),
telephoneNumber(person.telephoneNumber) { }
Person& operator = (Person const & person) {
if (& person != this) {
name = person.name;
telephoneNumber =person.telephoneNumber;
} /* endif */
return *this;
}
String const& getName() const {
return name;
}
String const& getTel() const{
return telephoneNumber;
}
String const & getKey() const {
return telephoneNumber;
}
};
// key function
inline String const & key (Person const & keyPerson){
return keyPerson.getName();
}
// hash function for the key
inline unsigned long hash (String const & key, unsigned long n){
return hash ( key.getText(), n ); // hash for char * defined in istdops.h
}