Oxygen Basic
Programming => Problems & Solutions => Topic started by: Frankolinox on June 30, 2014, 12:44:40 AM
-
lalala :)
-
class cAstroUnit
double a
double b
double c
METHOD constructor(a1 AS DOUBLE)
a = a1
b = a1*149597870691
c = b/1000
END METHOD
METHOD ToString() AS STRING
return a ", " b " meters = " c " kilometers"
END METHOD
END CLASS
cAstroUnit cA
new cAstroUnit cA 123
print "result: " ca.toString()
...this just compiles, can't guess if it is right too.
cheers
-
new and del are used to create / destroy persistent objects in a C++ish way.
When using these macros, constructor and destructor methods are expected, and the object is created from allocated memory, (like strings)
Trivial example:
class foo
bstring s
double a,b,c
method constructor(double m)
a=1.5*m
b=2.5*m
c=3.5*m
s="name"
end method
method destructor()
a=0
b=0
c=0
frees a
end method
method sum()
return a+b+c
end method
end class
new foo FooObj(10)
print FooObj.sum '75
...
del FooObj