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

Examples

Either clients should be able to delete polymorphically using a pointer to Base, or they shouldn’t. Each alternative implies a specific design:

  • Example 1: Base classes with polymorphic deletion. If polymorphic deletion should be allowed, the destructor must be public (else calling code can’t call it) and it must be virtual (else calling it results in undefined behavior).

  • Example 2: Base classes without polymorphic deletion. If polymorphic deletion shouldn’t be allowed, the destructor must be nonpublic (so that calling code can’t call it) and should be nonvirtual (because it needn’t be virtual).


  

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