beautypg.com

Summary – HP Integrity NonStop J-Series User Manual

Page 229

background image

Click on the banner to return to the user guide home page.

©Copyright 1996 Rogue Wave Software

Summary

In general, you may not have to supply definitions for all of these virtual functions when designing your own
class. For example, if you know that your class will never be used in sorted collections, then you do not need a
definition for compareTo(). Nevertheless, it is a good idea to supply definitions for all virtual functions anyway:
that's the best way to encourage code reuse!

Here then, is the complete listing for our class Bus:

BUS.H:
BEGIN FILE: bus.h
#ifndef __BUS_H__
#define __BUS_H__

#include
#include

class Bus : public RWCollectable {
RWDECLARE_COLLECTABLE(Bus)

public:

Bus();
Bus(int busno, const RWCString& driver);
~Bus();

// Inherited from class "RWCollectable":
Rwspace binaryStoreSize() const;
int compareTo(const RWCollectable*) const;
RWBoolean isEqual(const RWCollectable*) const;
unsigned hash() const;
void restoreGuts(RWFile&);
void restoreGuts(RWvistream&);
void saveGuts(RWFile&) const;
void saveGuts(RWvostream&) const;

void addPassenger(const char* name);
void addCustomer(const char* name);
size_t customers() const;
size_t passengers() const;
RWCString driver() const {return driver_;}
int number() const {return busNumber_;}

private:

This manual is related to the following products: