PDA

View Full Version : Another C++ Question



2
03-27-2001, 07:11 PM
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.

john
03-27-2001, 07:45 PM
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

john
03-27-2001, 07:49 PM
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).]