Jump to content
  • Advertisement
Sign in to follow this  
tonymontana

Function that takes unlimited arguments

This topic is 4987 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

Can you suggest me a tutorial about Functions that take unlimited arguments(especcially that issue i know funcitons).Sometime ago a moderator advised a good tutorial about Function pointer.Mayber he could.. Ps: also if you know ( a complete tutorial about Polymorphisim and dynamic_casti would be glad to know too) (i know inheritance,polymorphisim but sometimes i just can't say which function will be called when i looked at someone's code) thanks..

Share this post


Link to post
Share on other sites
Advertisement
Hi, you use a special operator (I think it's called elipsion or somethin).

Looks like this:

void Function(const char *myString, ...);

This would take a string variable and an unlimited list of arguments (useful for custom logging routines or fonts etc).

Check out NeHe tutorial 13 for a sample of using this.

Share this post


Link to post
Share on other sites
Either use a variadic function (C, very unsafe), or chained operators (like C++ iostreams). Depends on what exactly you're trying to achieve - care to explain?

Quote:
i know inheritance,polymorphisim but sometimes i just can't say which function will be called when i looked at someone's code


If a function is virtual, then the version that is called is the one that is associated with the type of the object - the one you used new with. If it is not virtual then it is the version associated with the type of the variable - if you have a Foo* then it'll call Foo's version.

Share this post


Link to post
Share on other sites
thanks fo your replys but i need tutorials about function with unlimited arguments and dynamic casts(its difference between other cast why i use that to convert parent to derived vb..).

if you have the adress of that tutorials post it.

Share this post


Link to post
Share on other sites
Quote:
Original post by tonymontana
thanks fo your replys but i need tutorials about function with unlimited arguments


Google found some.

Quote:
and dynamic casts

(its difference between other cast why i use that to convert parent to derived vb..).


Because dynamic_cast is the only one that will actually check that your object really is of the 'derived' type, relying on the run-time type information.

In most other circumstances, it is a static_cast that you'll want.

Share this post


Link to post
Share on other sites
Well both me and caffeineaddict gave you info on functions with unlimited arguments. It's pretty simple and the two examples we should you have easy to follow and useful code.

caffeineaddict: I used to use that function all the time ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!