Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 8. Object-Oriented Programming w... > Shortcomings of Encapsulation with F...

Shortcomings of Encapsulation with Functions

This is a great way to write software. However, there are a number of shortcomings in implementing encapsulation and information hiding with functions only. It is these drawbacks that C++ tries to eliminate with the introduction of classes.

One drawback is that access functions do not indicate to the maintainer what the designer knows, that these functions belong together and access the same data structure. In the examples in this chapter, I was putting the server functions together into the same listing for everyone to see. A better solution is to put functions isLeft(), isRight(), and symbolsMatch() into one file (functions accessing symbols), and the functions initStore(), isEmpty(), saveSymbol(), and getLast() into another file (functions accessing temporary storage).


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint