Using the C++ Math Library    

Printing, Exceptions, and Memory Management


This chapter describes how to write print handlers, handle exceptions, and replace default memory management.

Defining a Print Handler

The MATLAB C++ Math Library is designed to run on character-based terminals and in graphical, windowed environments. Simply using printf() or a similar routine is fine for character-terminal output but insufficient for output in a graphical environment. To support programs with graphical user interfaces, the library allows you to specify how it displays output.

The MATLAB C++ Math Library performs some output, in particular it displays error messages and warnings, but doesn't perform input. The MATLAB C++ Math Library's output requirements are very simple. The library formats its output into a character string internally and then calls a function, the print handler, that prints the string. If you want to change where or how the library's output appears, you must provide an alternate print handler.


 Defining Your Own Operators Providing Your Own Print Handler