Alex Rivera | Logout

IN/OUT Parameters and how to work with them in C++

Asked 2011-08-01T14:38:11.187
10

When reading documentation on functions from external libraries of different kinds I have always seen the documentation state that a variable has to be [IN/OUT]. Could someone give me a detailed understanding on how [IN/OUT] relates to parameters of a function being passed by reference or by value.

Here is an example of a function I have come across that tells me it needs an [IN/OUT] parameter:

Prototype: ULONG GetActivationState( ULONG * pActivationState );

Parameters

  • Type: ULONG*
  • Variable: pActivationState
  • Mode: IN/OUT
Edit
Report

1 Answer

1

I'm of a mixed mind regarding the use of in, out, and in/out.

Upside: When done properly, it communicates intent to the reader of the documentation.

Downside: Far too often it is not done properly. Those designations obviously are not a part of the language; they are either in comments or are in some document that is maintained separately from the code. I've seen far too many cases where a parameter was marked as "out" but the first thing done in the code with that parameter is to use it as a right-hand side value.

answered 2011-08-01T15:45:10.540

Your Answer