Main Content

C++ Language Opaque Objects

An opaque object has no properties and methods visible to MATLAB®. You can pass these objects to related functions that know how to work with them. Consult the documentation for the function that returned the opaque object to learn more about how to use it.

For example, this C++ code defines SessionHandle as typedef void*.

typedef void* SessionHandle;
SessionHandle getHandle(){
    // implement code here
};
void closeHandle(void * SessionHandle){};

After generating the MATLAB interface lib, call getHandle:

sessionHandle = clib.lib.getHandle
sessionHandle =
    SessionHandle is an opaque object.

The help for SessionHandle is:

clib.lib.SessionHandle    C++ opaque type.

You can pass the MATLAB sessionHandle variable to another function in the library:

clib.lib.closeHandle(sessionHandle)