summaryrefslogtreecommitdiff
path: root/Examples/octave/operator/runme.m
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/octave/operator/runme.m')
-rw-r--r--Examples/octave/operator/runme.m24
1 files changed, 24 insertions, 0 deletions
diff --git a/Examples/octave/operator/runme.m b/Examples/octave/operator/runme.m
new file mode 100644
index 0000000..e0f5906
--- /dev/null
+++ b/Examples/octave/operator/runme.m
@@ -0,0 +1,24 @@
+# Operator overloading example
+example
+
+a = example.ComplexVal(2,3);
+b = example.ComplexVal(-5,10);
+
+printf("a = %s\n",a);
+printf("b = %s\n",b);
+
+c = a + b;
+printf("c = %s\n",c);
+printf("a*b = %s\n",a*b);
+printf("a-c = %s\n",a-c);
+
+e = example.ComplexVal(a-c);
+printf("e = %s\n",e);
+
+# Big expression
+f = ((a+b)*(c+b*e)) + (-a);
+printf("f = %s\n",f);
+
+# paren overloading
+printf("a(3)= %s\n",a(3));
+