-
void pointers?
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...
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;
}
if you understand what i'm asking, how would i do that?
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..
-
Why don't you just make an integer called "bytes" and have that your offset or whatever it is you're doing?
Quzah.
-
ok..forget i even said bytes....
i can just use templates....i never used more the one type at a time for a template (ex; <class T, N>)....i was thinking what i wanted to do was more complex than it actually is.
-
I was wondering why you weren't templating it too. But there are many ways to do most things, so I figured you had something in mind why you weren't. :D
Quzah.