#include // // Class Definition // class Glass{ private: int volume; int filled; public: int fill(int); int drink(int); int empty(); int content(); Glass(int); ~Glass(); }; // // Implementation of Member Functions // Glass::Glass(int the_volume) { volume = the_volume; filled = 0; } Glass::~Glass() {} int Glass::fill(int quantity) { int free = volume - filled; if (quantity > free) { filled = volume; return free; }else{ filled += quantity; return quantity; } } int Glass::drink(int quantity) { int to_drink; if (quantity > filled) { filled = 0; return to_drink; }else{ filled -= quantity; return quantity; } } int Glass::empty() { int to_spill; filled = 0; return to_spill; } int Glass::content() { return filled; } // // Main // void main() { int e; Glass aGlass(1000); e=aGlass.fill(500); cout << "Filling glass with: " << e << endl; e=aGlass.drink(250); cout << "Drinking: " << e << endl; cout << "The glass contains: " << aGlass.content() << endl; aGlass.empty(); }