Function with unnamed parameter

3

What is the reason for declaring a function with this signature?

void funcao1(Pessoa&);
void funcao2(Pessoa&,void*);

void XN_CALLBACK_TYPE UserCalibration_CalibrationComplete(xn::SkeletonCapability& /*capability*/, XnUserID nId, XnCalibrationStatus eStatus, void* /*pCookie*/)
{
    XnUInt32 epochTime = 0;
    xnOSGetEpochTime(&epochTime);
    .
    .
    .
}
    
asked by anonymous 11.07.2015 / 01:58

1 answer

2

You are declaring two functions, both return nothing.

Both have a first parameter that will be a reference for a data of type Pessoa . This only exists in C ++, not in C. Not to be confused with the & used in variables that is a reference operator, that is, it takes the memory address of the variable. Although the symbol is the same, the features look alike, they are quite different things. In C ++ references are preferable to pointers whenever possible.

Do not confuse the parameter xn::SkeletonCapability& with the argument % of_with% in the line within the example function, are very different things. In the context of the parameter and the placed position indicates that you are declaring a reference. In the context of the argument you are telling the compiler to take the memory address of the variable to be used as an argument and pass that address to the pointer that the &epochTime function is expecting.

The second function also has a second parameter whose type is not defined. It's a joker.

This is not very common in C ++, there are other ways to solve this. But this is a way of determining that the parameter can receive anything. This form is most common in C.

This is a pointer to xnOSGetEpochTime , in a way it can be read as a pointer to any data, of any type. In other words, you can pass anything to this parameter.

Note that this is just the declaration of functions and not their definition. In the definition it is necessary to place, in addition to the parameter type, a variable that will receive the data.

In the example placed in later edition shows that two parameters are being disabled with comments. Probably they are not being used inside the function, which would generate a warning . Probably this was the way they used to have the variable not be created but still maintain the positions of the parameters.

11.07.2015 / 02:47