Jump to content
  • Advertisement
MarcusAseth

Optional arguments confusion

This topic is 365 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 am watching at this page -> https://msdn.microsoft.com/en-us/library/windows/desktop/dd371301(v=vs.85).aspx

HRESULT CreateStrokeStyle(
  [ref]          const D2D1_STROKE_STYLE_PROPERTIES &strokeStyleProperties,
  [in, optional] const FLOAT                        *dashes,
                       UINT                         dashesCount,
  [out]                ID2D1StrokeStyle             **strokeStyle
);

notice the second optional argument followed by two non-optional ones...how in the world am I supposed to use the function without passing the second argument, if it is on the middle?! x_x

Share this post


Link to post
Share on other sites
Advertisement

That optional argument "const FLOAT *dashes" is a pointer. Means you can either supply actual data - array with dashes lengths, or not supply anything. For pointers/arrays that means passing zero/nullptr. You can't omit it in a sense of C/C++ optional arguments, but you can some give data or not, that's what "optional" means in this case.

Share this post


Link to post
Share on other sites

Note that this is just a convention used in this particular documentation - there's no official "optional argument" in C++, except perhaps the case when you have function overloads with different length argument lists.

Share this post


Link to post
Share on other sites
11 minutes ago, Kylotan said:

Note that this is just a convention used in this particular documentation - there's no official "optional argument" in C++, except perhaps the case when you have function overloads with different length argument lists.

I think I was under the assumption that optional referred to C++ "Default arguments" (because they are optional), but indeed not the case

Edited by MarcusAseth

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!