Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Kyger

[C/C++] Function Parameter: void?

This topic is 5213 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Sure it wasn''t a void*? A void* is just an address. It can point to anything at all.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!