diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 165f44667..9ff29b4ba 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -30,8 +30,8 @@
-can be used from Scilab like this: +can be used in Scilab like this:
@@ -738,15 +738,88 @@ ans = --> delete_Point(p2);
+Inheritance is supported. SWIG knows the inheritance relationship between classes. +
+ ++A function is only generated for the class in which it is actually declared. +But if one of its parameter is a class, any instance of a derived class is accepted as argument. +
+ ++This mechanism applies also for accessor functions : these one are generated only in the class in which they are defined. +But any instance of a child class can be used as argument of these accessor functions. +
+ ++For example, let's take a base class Shape and two child classes Circle and Square: +
+ +
+%module example
+
+%inline %{
+
+class Shape {
+public:
+ double x, y;
+ void set_location(double _x, double _y) { x = _x; y = _y; }
+ virtual double get_perimeter() { return 0; };
+};
+
+class Circle : public Shape {
+public:
+ int radius;
+ Circle(int _radius): radius(_radius) {};
+ virtual double get_perimeter() { return 6.28 * radius; }
+};
+
+class Square : public Shape {
+public:
+ int size;
+ Square(int _size): size(_size) {};
+ virtual double get_perimeter() { return 4 * size; }
+};
+
+%}
++To set the location of the Circle, we have to use the function set_location() of the parent Shape. +But we can use either use the get_perimeter() function of the parent class or the child class: +
+ ++--> c = new_Circle(3); + +--> Shape_set_location(c, 2, 3); +--> Shape_x_get(c) + ans = + + 2. + +--> Circle_get_perimeter(c) + ans = + + 18.84 + +--> Shape_get_perimeter(c) + ans = + + 18.84 +
Templates are supported. See the SWIG general documentation on how templates are interfaced in SWIG.
An example of templates can be found in Examples/scilab/templates.
The Standard Template Library (STL) is partially supported. See STL for more details.