The following example shows how an object is created which is visible to all functions of a file. Since it is created by new() it has to be deleted explicitly. The section 7.8 uses the same example but with unique_ptr.
// #include <tango.h> #include <string> #include "nxIO.h" static NXSelWriter *wrPtr; int tng_nexus_init() { ... wrPtr = new NXSelWriter( selectorName); ... } int tng_nexus_record() { wrPtr->loopStep(); } int tng_nexus_final() { wrPtr->closeEntry(); wrPtr->closeFile(); delete wrPtr; } int main(int argc, char ** argv) { tng_nexus_init(); // the scan loop for(int i =0 ;i<10; i++){ tng_nexus_record(); } tng_nexus_final(); }