Class with Hidden State Example

class Account { 
    // Specification fields: 
    //   ActNo = unique id of Account 
    //   balance = amount of money owed for phone services 
    //   fee = monthly fee
public: 
    explicit Account (const AccountNo& num); 
      // ensures: initializes this to an Account whose 
      //            Actno == num 
      //            balance == 0 
      //            fee == 30 

    virtual void bill (); 
      // modifies:  this->balance 
      // ensures:  this->balance = this@pre->balance + fee 

    virtual void print() const;
      // modifies:  cout 
      // ensures:  cout = cout@pre + this
}

results matching ""

    No results matching ""