data types types...

This is a discussion on data types types... within the C++ Programming forums, part of the General Programming Boards category; im pretty new to this kind of C++ and i was wondering if there is a way to determine what ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    29

    data types types...

    im pretty new to this kind of C++ and i was wondering if there is a way to determine what is the type of a pointer. say i got a void* that points to an int. how can i detect that? or pass an int* to a void* accepting function, then identifying its type.(e.g: without overloading...).

    any help?

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You don't. Keep the original pointer type. Overload the function or make it a template.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    If there is no alternative whatsoever (e.g. you have a void * from a callback function) you just need to make sure you know the real type of the pointer. Pass only a single type of pointer in to it.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  4. #4
    Registered User
    Join Date
    Jun 2006
    Posts
    29
    thanks for your posts. i think ill simply use void* and overloading. thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extending basic data types.
    By nempo in forum C++ Programming
    Replies: 23
    Last Post: 09-25-2007, 04:28 PM
  2. Replies: 4
    Last Post: 06-14-2005, 06:45 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 07:51 PM
  5. Using enumerated data types
    By SXO in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2001, 07:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21