Jump to content

Abstract type: Difference between revisions

Added BBC BASIC
(Added BBC BASIC)
Line 221:
return
</lang>
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
BBC BASIC is a procedural language with no built-in OO features. The CLASSLIB library implements simple Object Classes with multiple inheritance; an abstract class may be created without any instantiation, the sole purpose of which is for other classes to inherit from it. At least one member or method must be declared, but no error will be generated if there is no implementation:
<lang bbcbasic> INSTALL @lib$+"CLASSLIB"
REM Declare a class with no implementation:
DIM abstract{method}
PROC_class(abstract{})
REM Inherit from the abstract class:
DIM derived{member%}
PROC_inherit(derived{}, abstract{})
PROC_class(derived{})
REM Provide an implementation for the derived class:
DEF derived.method : PRINT "Hello world!" : ENDPROC
REM Instantiate the derived class:
PROC_new(instance{}, derived{})
REM Test by calling the method:
PROC(instance.method)</lang>
 
=={{header|C}}==
Doing abstract types in C is not particularly trivial as C doesn't really support classes. The following series will show an abstract type, followed by a realizable class that provides the abstract interface, and finally followed by an example of usage.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.