#includeusing namespace std; class Person { protected: char *gender; double height, weight; public: Person(char *g, double h, double w) {gender = g; height = h; weight = w;} void walks(int steps, char *dir) { cout << "I walked " << steps << " steps in " << dir << " direction\n"; } void talks(void) { cout << "Hello World!!\n"; } }; class MailMan : public Person { protected: int bagWeight, routeLen; public: MailMan(int b, int r, char *g, double h, double w): Person(g, h, w) {bagWeight=b; routeLen=r;} int delivery_time(void) {return bagWeight * routeLen;} void mailboxes_seen(void) { cout << "I saw " << routeLen << " mailboxes today!\n"; } }; int main (void) { Person *fred = new Person("male", 6.0, 175.5); fred->talks(); fred->walks(5, "north"); MailMan *joe = new MailMan(5, 10, "male", 5.7, 140.2); joe->mailboxes_seen(); joe->talks(); cout << "Joe's estimated delivery time is " << joe->delivery_time() << "\n"; joe->walks(9, "left"); return 0; } //
Enjoy the ups and downs of riding bikes thru sun, rain, snow, darkness and everything in between.
Sunday, November 20, 2011
last 1 for now
I am about done with joe and fred, here is the last one for a while before more work. yippee aye kiyay
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment