This package provides an example of how to wrap a C++ class in a MATLAB class, via a mex interface, safely, without memory leaks, whilst achieving an interface in MATLAB that is similar to the underlying C++ interface.
After downloading, first mex the C++ wrapper using:
>> mex class_interface_mex.cpp
Then test the various methods:
>> a = class_interface(); % Create a class instance
>> train(a) % Train the class - dummy method
>> test(a) % Test the class - dummy method
>> clear a; % Destroy the instance
Look in class_interface.m and class_interface_mex.cpp to see how this is implemented, and copy the structure to interface with your own C++ classes.
This submission is inspired by the following newsgroup thread:
Thanks to all those who have contributed.