Instantiating RWDBTBuffer
Because
RWDBTBuffer is a template class, you instantiate the class on a particular type, the type
pointed to by the pointer that the class encapsulates. To demonstrate how to instantiate
RWDBTBuffer, we first create a pointer to some data:
long *pLong = new long;
Next, we create an
RWDBTBuffer, specifically an
RWDBTBuffer<long>, to encapsulate the pointer:
RWDBTBuffer<long> aBuffer(pLong);
If we want our
RWDBTBuffer to encapsulate a pointer to an array of objects rather than a single object, we pass in the number of elements in the array:
long *pLongs = new long[100]; // create array of 100 longs
RWDBTBuffer<long> anotherBuffer(pLongs, 100); // encapsulate it
Of course, we can also create
RWDBTBuffers for more than just C++ fundamental types. All the primitive types of the Essential Tools Module and the DB Interface Module are supported:
RWCString *bunchOfStrings = new RWCString[200];
RWDBTBuffer<RWCString> stringsBuffer(bunchOfStrings, 200);