Thread: void pointers?

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    719

    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..
    Last edited by misplaced; 10-12-2004 at 03:35 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why don't you just make an integer called "bytes" and have that your offset or whatever it is you're doing?

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    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.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. i cannot see the mouse arrow
    By peachchentao in forum C Programming
    Replies: 6
    Last Post: 12-10-2006, 04:14 AM
  4. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM