|
|
# include <Vblock.h>template <class T> class Vblock{ public: // similar to Block(3C++) };
A Vblock is just like a Block (see Block(3C++)), except that (for technical reasons having to do with G2++) some of its member functions are virtual. If a G2++ record definition (see G2++.4C++) specifies an array, the corresponding declaration generated by g2++comp(1C++) in the .h file will contain a Vblock (see the Example).
When compiled by g2++comp(1C++), the following record definition
usr.g
usr
name *
proj
*(100) LONG
generates a .h file containing the following:
usr.h
...
typedef struct USR{
String name;
Vblock<LONG> proj;
USR();
}USR;
A client program may manipulate the proj field just as though it were a Block, e.g.,
#include "usr.h"
main(){
USR u;
for(int i=0;i<100;i++){
u.proj.reserve(i);
u.proj[i] = i;
}
}