In c++ do you have 'out parameters' like in c#?
In c# the method signature would be:
bool TryGetValue(int key, out OrderType order)
The idea is the variable may not be assigned before passed but MUST be assigned before exiting the method.
MSDN out params link: http://msdn.microsoft.com/en-us/library/aa645764(v=vs.71).aspx
There is nothing as strict as C# out
parameters in C++. You can use pointers and references to pass values back but there is no guarantee by the compiler that they are assigned to within the function. They are much closer to C# ref
than out
// Compiles just fine in C++
bool TryGetValue(int key, OrderType& order) {
return false;
}
No, there are no out
parameters in C++ that force you to assign to it before exiting the function. Pointers and references are more like ref
parameters in C#.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With