manpagez: man pages & more
info octave
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

33.4.1 Function Overloading

Any Octave function can be overloaded, and allows a object specific version of this function to be called as needed. A pertinent example for our polynomial class might be to overload the polyval function like

This function just hands off the work to the normal Octave polyval function. Another interesting example for an overloaded function for our polynomial class is the plot function.

which allows polynomials to be plotted in the domain near the region of the roots of the polynomial.

Functions that are of particular interest to be overloaded are the class conversion functions such as double. Overloading these functions allows the cast function to work with the user class and can aid in the use of methods of other classes with the user class. An example double function for our polynomial class might look like.


© manpagez.com 2000-2024
Individual documents may contain additional copyright information.