A struct is an assembled object that contains variables, functions, or further structs (similar to a C++ class). Members of a struct are individually accessed using the struct name, followed by a '.' and the member name. Example of a counter class that controls a counter and stores it in a file:
#include <gxAPI/fs.h> struct tCounter { bool tryLoad() { bool boResult = true; try { fs.loadFile("counter.dat", this); } catch(...) { boResult = false; } return boResult; } void store() { fs.saveFile("counter.dat", this); } void count() { ++miValue; } int miValue; }; // We create an object... tCounter cnt; // The first time this will return false. bool boSuccess = cnt.tryLoad(); print(MTR("Load: %success% | Counter Value = %value%") << boSuccess << cnt.miValue); cnt.count(); // Store new counter values. cnt.store();
► latest version online