Abstract type: Difference between revisions
Content added Content deleted
Line 2,942: | Line 2,942: | ||
EQUALTO := T = K QUA TEXTHASHKEY.T; |
EQUALTO := T = K QUA TEXTHASHKEY.T; |
||
END TEXTHASHKEY; |
END TEXTHASHKEY; |
||
</lang> |
|||
=={{header|Smalltalk}}== |
|||
A class is declared abtract by responding to the query <tt>isAbstract</tt> with true, and defining the required protocol for subclasses to raise an error notification. Optionally, instance creation can be blocked. Typically, the IDE provides a menu function to generate these definitions automatically: |
|||
<lang smalltalk>someClass class >> isAbstract |
|||
^ true |
|||
someClass class >> new |
|||
^ self abstractClassInstantiationError |
|||
someClass >> method1 |
|||
^ self subclassResponsibility |
|||
</lang> |
</lang> |
||