i've been playing around with fixed sized files and i decided that i want to create a templated class to work with them...just a simple database like interface. the will be 3 classes...one of type T (any kind of class [with a data member, duh] ), one which is a (container?) class called Record, and another class that is called, i dunno, FileManager... the record class will inherit from type T. Record only has one data member called Key, which is a pointer to a data member in type T...but i don't want it to point to a SPECIFIC data member...here, let me show you come code...
if you understand what i'm asking, how would i do that?Code:class foo { int x; int y; char id; } template <class T> class Record : private T //i'm thinking i will need to use private //but that's part of my question that i //haven't asked yet { <type void?> *key; } template <class T> Record::Record(<type void?> *dataMemberOfFooYouWantToPointTo) { key = dataMemberOfFooYouWantToPointTo; }
just to rephrase, say x and y are 4 bytes each, and i want the key to be id and to tell *key to dereference the data 8 bytes into the object foo......
but in another instantiation of type Record i want the key to dereference y..