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
  • PrintPrint
Share this Page URL
Help

12. OOA&D > Abstract Syntax

Abstract Syntax

You can add an abstract class from the Class Designer, but you can’t define abstract members. You have to do that in code.

image

Where the Class Designer really comes into its own when working with abstract classes is in implementing the necessary members in their descendents. Simply right-click an inheriting class and choose Implement Abstract Class from the Intellisense menu.

image

As you might expect, the code for implementing an abstract class or abstract member looks very like the code for an interface. Only the signature is defined, without any implementation, marked with the MustInherit or MustOverride keyword.

image

Put on Your Thinking Hat

image

Given the descriptions below, which of these do you think should be implemented as an abstract class, and which should be implemented as an interface? Hint: If the descriptions don’t seem clear to you, think about where the types might sit in a hierarchy, specifically, whether the members might be needed in more than one limb of the tree.


  

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
  • PrintPrint