< previous page page_400 next page >

Page 400
LISTING 22.3 continued
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
252:       pAddress Sender(PostMaster, jliberty@PostMaster, Jesse Liberty);
253:       pAddress Recipient(PostMaster, sliberty@PostMaster, Stacey Liberty);
254:       PostMasterMessage PostMasterMessage(Sender, Recipient, Saying Hello, 0);
255:       cout << Message review \n;
256:       cout << From:\t\t << PostMasterMessage.GetSender() << endl;
257:       cout << To:\t\t << PostMasterMessage.GetRecipient() << endl;
258:       cout << Subject:\t << PostMasterMessage.GetSubject() << endl;
259:       return 0;
260:   }

Warning: If you receive a can't convert error, remove the const keywords from lines 207 to 209.

Output:
Post Master Message created.
Message review
From:      Jesse Liberty
To:        Stacey Liberty
Subject:   Saying Hello
Analysis: On line 4, pDate is type-defined to be an unsigned long. It is not uncommon for dates to be stored as a long integer, typically as the number of seconds since an arbitrary starting date such as January 1, 1900. In this program, this is a place-holder; you would expect to eventually turn pDate into a real class.
On line 5, an enumerated constant, SERVICE, is defined to allow the address objects to keep track of what type of address they are, including PostMaster, CompuServe, and so forth.
Lines 7163 represents the interface to and implementation of String, along much the same lines as you have seen in previous chapters. The String class is used for a number of member variables in all the message classes and in various other classes used by messages, and as such, it is pivotal in your program. A full and robust String class will be essential to making your message classes complete.
On lines 165185, the pAddress class is declared. This represents only the fundamental functionality of this class, and you would expect to flesh this out once your program is better understood. These objects represent essential components in every message: both the sender's address and that of the recipient. A fully functional pAddress object will be able to handle forwarding messages, replies, and so forth.

 
< previous page page_400 next page >

If you like this book, buy it!