Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Another C++ Question

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    29

    Another C++ Question

    Here's something I've been wondering how to do for a while... I've seen it done in a few places, and I, frankly, have no idea where to look for how it was done.

    Classnames as a parameter in a function. For example, va_arg's second parameter. Thanks a ton for any help.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    839

    Re: Another C++ Question

    maaaayyyte... you really need to find a C++ site, or something. here lies the opengl site.

    but, anyway, classes are just like a type:

    class Goat
    {
    };

    void foobar(Goat herd)
    {
    }

    and so on.

    cheers,
    John

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    839

    Re: Another C++ Question

    oh, hang. let me wake up. <drinks coffee>

    sorry, now i'm with you. va_arg is a macro, not a function def. you CAN"T give a "type" as a paramter. (there are ways of getting around this, notably fucntions ptrs in C and the whole object orientated / inheritenance stuff in C++)

    va_arg is a macro with textual subsitution. for examole:

    #define frog(t) sizeof(t)

    means i can now do this:

    frog(int);
    frog(char*);

    and so on. because its JUST a macro. (va_arg uses the type to index the void ptr into the stack, incidentially)

    cheers
    John

    [This message has been edited by john (edited 03-27-2001).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •