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 9. C++ Class as a Unit of Modula... > Elimination of Name Conflicts

Elimination of Name Conflicts

Class opening and closing braces (and the closing semicolon) form the class scope pretty much in the same way as an ordinary structure forms a separate scope for its fields. This class scope, which is nested within the file scope, is similar to the scope of an ordinary structure. The difference is that the class scope can nest function scopes.

Nonmember functions (e.g., access functions in Listing 9.1) are global functions, and their names must be unique in the program (unless they are made static in the file scope, but only a small minority of functions can be made static in the file scope; more on static functions can be found in Chapter 6, "Memory Management. The Stack and The Heap," and later in this chapter). Normally, only those team members that use class Cylinder should learn about these function names because they are going to call this functions. In practice, every team member should learn about these names to avoid accidental name conflicts. This information obstructs the channels of communication among programmers.


  

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