void pointer

Discussion in 'C++' started by Niks, Sep 7, 2005.

  1. Niks

    Niks Guest

    what is a void pointer?
    Niks, Sep 7, 2005
    #1
    1. Advertising

  2. Niks

    Jim Langston Guest

    "Niks" <> wrote in message
    news:...
    > what is a void pointer?


    void* MyPointer;
    Jim Langston, Sep 7, 2005
    #2
    1. Advertising

  3. Niks wrote:
    > what is a void pointer?


    You mean a pointer to void?

    A generic pointer, a plain address. That type is returned from 'malloc'
    function and from 'operator new', and is accepted by 'operator delete'
    as an argument. Usually a pointer to void is used to hold a pointer to
    an object of any type or of an unknown type. Has the same alignment
    requirements and the same representation as 'char*'. Along with the
    requirement that 'void*' can hold a pointer to any object comes the
    standard conversion from a pointer to object to a pointer to void. That
    conversion is implicit and the reverse can be done using 'static_cast'.

    V
    Victor Bazarov, Sep 7, 2005
    #3
  4. Niks

    Dan Cernat Guest

    Victor Bazarov wrote:
    > Niks wrote:
    > > what is a void pointer?

    >
    > You mean a pointer to void?
    >
    > A generic pointer, a plain address. That type is returned from 'malloc'
    > function and from 'operator new', and is accepted by 'operator delete'
    > as an argument. Usually a pointer to void is used to hold a pointer to
    > an object of any type or of an unknown type. Has the same alignment
    > requirements and the same representation as 'char*'. Along with the
    > requirement that 'void*' can hold a pointer to any object comes the
    > standard conversion from a pointer to object to a pointer to void. That
    > conversion is implicit and the reverse can be done using 'static_cast'.
    >
    > V


    Can it hold (is it big enough to hold) a pointer to a member function?
    I know that the pointers to member functions are implementation
    specific, but I was wondering if the standard says anything about this.

    thanks,
    Dan
    Dan Cernat, Sep 7, 2005
    #4
  5. Dan Cernat wrote:
    > Victor Bazarov wrote:
    >
    >>Niks wrote:
    >>
    >>>what is a void pointer?

    >>
    >>You mean a pointer to void?
    >>
    >>A generic pointer, a plain address. That type is returned from 'malloc'
    >>function and from 'operator new', and is accepted by 'operator delete'
    >>as an argument. Usually a pointer to void is used to hold a pointer to
    >>an object of any type or of an unknown type. Has the same alignment
    >>requirements and the same representation as 'char*'. Along with the
    >>requirement that 'void*' can hold a pointer to any object comes the
    >>standard conversion from a pointer to object to a pointer to void. That
    >>conversion is implicit and the reverse can be done using 'static_cast'.
    >>
    >>V

    >
    >
    > Can it hold (is it big enough to hold) a pointer to a member function?


    No. Only a pointer to an object.

    > I know that the pointers to member functions are implementation
    > specific, but I was wondering if the standard says anything about this.


    It says "A void* shall be able to hold any object pointer."

    V
    Victor Bazarov, Sep 7, 2005
    #5
  6. Niks

    Dan Cernat Guest

    Victor Bazarov wrote:
    > Dan Cernat wrote:
    > > Victor Bazarov wrote:
    > >

    [...]
    >
    > It says "A void* shall be able to hold any object pointer."
    >
    > V


    Thanks,
    Dan
    Dan Cernat, Sep 7, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ollej Reemt
    Replies:
    7
    Views:
    525
    Jack Klein
    Apr 22, 2005
  2. Stig Brautaset

    `void **' revisited: void *pop(void **root)

    Stig Brautaset, Oct 25, 2003, in forum: C Programming
    Replies:
    15
    Views:
    788
    The Real OS/2 Guy
    Oct 28, 2003
  3. Replies:
    5
    Views:
    826
    S.Tobias
    Jul 22, 2005
  4. Hakirato
    Replies:
    4
    Views:
    876
    Alf P. Steinbach
    Oct 5, 2006
  5. Replies:
    1
    Views:
    405
    Victor Bazarov
    May 23, 2007
Loading...

Share This Page