0

I am reading a C++ code and came across a function:

double Nm_poissons_ratio(double /*Temp*/) { double PR(0.0); PR = 0.31; return PR; } 

I don't understand what is the effect of /* */ characters which surround the Temp variable.

Thanks

2
  • @ Ami, Cory & ARL: Thank you for the answer. It is interesting that in the function argument we have variable type but no variable; wondering how does compiler interpret this type of argument. Commented Jun 19, 2015 at 20:42
  • There is a variable. It just doesn't have a name you can use. Commented Jun 19, 2015 at 20:42

3 Answers 3

4

If you write

double Nm_poissons_ratio(double Temp) 

the compiler will warning. about an unused variable.

In this case, the coder wanted to retain the signature for some reason, but to avoid the warning. He/she therefore put a comment to show what it originally was.


Why is this the signature? It's hard to know.

  • Perhaps this is an intermediate version of the code, and he/she plans to use this parameter in the future (this is actually an excellent case to retain the warning).

  • Perhaps it's passed as a callback to some function that expects a specific signature.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the answer. It is interesting that in the function argument we have variable type but no variable; wondering how does compiler interpret this type of argument.
2

It means that the function takes a double argument, but they are commenting out the name (hence the /* */) because the argument to be named.

Likely because the compiler will warn them about an unused formal argument, since they do not use Temp anywhere in the function.

Comments

1

All that is happening is the developer is commenting out a piece of code. Basically a comment tells the computer to ignore this piece of code. So, if you were developing a programming you would:

/* This is hidden to everyone BUT the programmer. */ 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.