11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

284Part IV: InheritanceAccountFigure 22-4:A moredevelopedbankaccounthierarchy.ConventionalTimedSavings Checking CD 501KSpecialCheckingStockMarketMutualFundsSuppose that the bank allows account holders to access checking and stockmarket accounts remotely. Withdrawals from other account types can bemade only at the bank. Although the class structure in Figure 22-4 seems natural,the one shown in Figure 22-5 is also justifiable given this information.The programmer must decide which class structure best fits the data andleads to the cleanest, most natural implementation.AccountFigure 22-5:RemotelyAccessibleLocallyAccessibleAn alternateclass Stock Checking Market Savingshierarchy tothe one inFigure 22-4. SpecialChecking CD MutualFunds 501KImplementing Abstract ClassesAs intellectually satisfying as factoring is, it introduces a problem of its own.Return one more time to the bank account classes, specifically the commonbase class Account. Think for a minute about how you might go about definingthe different member functions defined in Account.Most Account member functions are no problem because both account typesimplement them in the same way. Implementing those common functions withAccount::withdrawal() is different, however. The rules for withdrawing from

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!