Thread: Class question.

  1. #1
    Registered Abuser Loic's Avatar
    Join Date
    Mar 2007

    Class question.

    Could a class that looked like this be used to hold anything else other than pointers? With out modifying any of it, just adding to itů well completing it?

    class stack
    int depth;
    int current;
    void *stack_layer[100];
    int push(void *myobject) { ů }
    void* pop(void)

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you have similar sized objects, you could make the storage type a union.

    But all the smart money goes on templates nowadays.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  2. Replies: 8
    Last Post: 10-02-2005, 12:27 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. question about DLL's and class functions
    By btq in forum Windows Programming
    Replies: 2
    Last Post: 02-25-2003, 06:08 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM