diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 24cfbfd31..977f8c3b5 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -33,6 +33,7 @@
+C++ operators are partially supported. +Operator overloading exists in Scilab, but a C++ operator is not (in this version) wrapped by SWIG with a Scilab operator, but with a function. +It is not automatic, you have to rename each operator to wrap (with the instruction %rename) to give the name of wrapping function. +
+ ++Let's see it on an example of class with two operators + and double(): +
+ +
+%module example
+
+%rename(plus) operator +;
+%rename(toDouble) operator double();
+
+%inline %{
+
+class Complex {
+public:
+ Complex(double re, double im) : real(re), imag(im) {};
+
+ Complex operator+(const Complex& other) {
+ double result_real = real + other.real;
+ double result_imaginary = imag + other.imag;
+ return Complex(result_real, result_imaginary);
+ }
+ operator double() { return real; }
+private:
+ double real;
+ double imag;
+};
+
+%}
++
+-->c1 = new_Complex(3, 7); + +-->c2 = Complex_plus(c, new_Complex(1,1)); + +-->Complex_toDouble(c2) + ans = + + 4. +
The Standard Template Library (STL) is partially supported. See STL for more details.