//: C08:Trash.h // From "Thinking in C++, Volume 2", by Bruce Eckel & Chuck Allison. // (c) 1995-2004 MindView, Inc. All Rights Reserved. // See source code use permissions stated in the file 'License.txt', // distributed with the code package available at www.MindView.net. // Describing trash. #ifndef TRASH_H #define TRASH_H #include class Trash { float _weight; public: Trash(float wt) : _weight(wt) {} virtual float value() const = 0; float weight() const { return _weight; } virtual ~Trash() { std::cout << "~Trash()" << std::endl; } }; class Aluminum : public Trash { static float val; public: Aluminum(float wt) : Trash(wt) {} float value() const { return val; } static void value(float newval) { val = newval; } }; class Paper : public Trash { static float val; public: Paper(float wt) : Trash(wt) {} float value() const { return val; } static void value(float newval) { val = newval; } }; class Glass : public Trash { static float val; public: Glass(float wt) : Trash(wt) {} float value() const { return val; } static void value(float newval) { val = newval; } }; #endif // TRASH_H ///:~