Singleton: Difference between revisions

mNo edit summary
Line 1,644:
 
=={{header|OxygenBasic}}==
 
The singleton contains static members only. It may be instantiated any number of times, but the members will all be shared.
<lang oxygenbasic>
Class Singleton
class singleton
static sys inst a,b,c'private
int instantiated() { return inst }
static string s,t,u
void constructor(){ if not inst then inst=@this }
static double x,y,z
'all other methods start with @this=inst
end class
 
'TEST
'====
 
'if not singleton.instantiated
singleton A
new Singleton MySingleton
singleton B
'endif
A.c=3
</lang>
print B.c 'result 3
print sizeof B 'result 0
</lang>
 
=={{header|Oz}}==
54

edits