Can parentheses accept arbitrary identifiers as arguments? C ++

For instance,

(const int)* someInt;

valid code?

If so, this statement is different from

const int* someInt;

?

+1
source share
4 answers

You can place arbitrarily many parentheses around expressions without changing the value. But you cannot do the same with types. In particular, as others have pointed out, parenthese in your code changes the value from the declaration in casting.

+2
source

You can style c with any type inside, but the expression you are trying to drop may not be able to be executed that way.

. .

0

This seems valid to me because you can specify a constant value each time.

I do not think that there is a difference between them.

0
source

if someIntdefined as

int *someInt;

then

(const int)* someInt;

. In addition, you will encounter an error.

You interfered with the pointer to intand passed the resulting value const int. And yes, this statement without purpose is lost.

int rtn = (const int)* someInt;
0
source

All Articles