Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Simula
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Classes, subclasses and virtual procedures === A more realistic example with use of classes,<ref name="CommonBase"/>{{rp|1.3.3, 2}} subclasses<ref name="CommonBase"/>{{rp|2.2.1}} and virtual procedures:<ref name="CommonBase"/>{{rp|2.2.3}} '''Begin''' '''Class''' Glyph; '''Virtual''': '''Procedure''' print '''Is''' '''Procedure''' print;; '''Begin''' '''End'''; Glyph '''Class''' Char (c); '''Character''' c; '''Begin''' '''Procedure''' print; OutChar(c); '''End'''; Glyph '''Class''' Line (elements); '''Ref''' (Glyph) '''Array''' elements; '''Begin''' '''Procedure''' print; '''Begin''' '''Integer''' i; '''For''' i:= 1 '''Step''' 1 '''Until''' UpperBound (elements, 1) '''Do''' elements (i).print; OutImage; '''End'''; '''End'''; '''Ref''' (Glyph) rg; '''Ref''' (Glyph) '''Array''' rgs (1 : 4); ''! Main program;'' rgs (1):- '''New''' Char ('A'); rgs (2):- '''New''' Char ('b'); rgs (3):- '''New''' Char ('b'); rgs (4):- '''New''' Char ('a'); rg:- '''New''' Line (rgs); rg.print; '''End'''; The above example has one [[Superclass (computer science)|super class]] (Glyph) with two [[Subclass (computer science)|subclasses]] (<code>Char</code> and <code>Line</code>). There is one [[Virtual function|virtual procedure]] with two [[implementation]]s. The execution starts by executing the main program. Simula lacks the concept of [[abstract class]]es, since classes with pure [[Virtual function|virtual procedures]] can be [[Instance (computer science)|instantiated]]. This means that in the above example, all classes can be instantiated. Calling a pure virtual procedure will however produce a [[Runtime (program lifecycle phase)|run-time]] [[Error message|error]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)