[C/C++] Function Parameter: void?
I''ve seen a few functions where a parameter was of type void. I''m not talking about just having the word void in there to show that there are no parameters at all, but what I''m talking about is:
int functionName(int randomInt, void someVariable)
What''s it mean?
--------------------------------
Junaris Games - An Amateur Game Development Team
Current Project: Codename: Orbo
Come support us! It gives us motivation
My understanding is that any type can be typecasted onto the void. Functions like malloc return a void*, this is why you have to typecast the malloc function when you call it.
So I you call it something like this:
functionName(num1, (char*)string1);
This is old-style C programming though... use templates with C++.
Somebody correct me if I''m wrong though.
So I you call it something like this:
functionName(num1, (char*)string1);
This is old-style C programming though... use templates with C++.
Somebody correct me if I''m wrong though.
i think you might not have looked properly its most probably a pointer to void syntax:
void foobar(void* void_ptr);
which is just a generic pointer you can't do much with them, used mainly in C to allow you to store the address of any type. You can do a thew advanced tricks with them but not type safe, not really needed in C++, except for certain suitutions
[edited by - snk_kid on May 6, 2004 7:28:01 PM]
void foobar(void* void_ptr);
which is just a generic pointer you can't do much with them, used mainly in C to allow you to store the address of any type. You can do a thew advanced tricks with them but not type safe, not really needed in C++, except for certain suitutions
[edited by - snk_kid on May 6, 2004 7:28:01 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement