The only bad thing about C++ is C

Pages: 1... 345
closed account (1vRz3TCk)
Why do you consider old libraries such as string.h for ASCIZ arrays to be in the "heart of the language"?
I don't. I consider string.h to be a library for the C language, cstring on the other hand I consider to be...well a library for the C++ language but not the language.
closed account (1vRz3TCk)
signed int(myDouble); is not valid C++
Might I suggest that you read 5.2.3 Explicit type conversion (functional notation) in the C++ standard (to my knowledge it is not valid C but is valid C++).
Yes, I learned that syntax from this very site. See "Explicit conversion":
http://www.cplusplus.com/doc/tutorial/typecasting/
@CodeMonkey

No it's not. int(something) is a cast of something to int - you're right with that. But it doesn't work with signed int because the int part alone is already a token, so it's "signed" before "a cast to int", which is invalid. Same with int*(something) - for the compiler, *(something) is application of the dereference operator, so it's actually int whatSomethingPointsTo which is also invalid C++.
Last edited on
closed account (1vRz3TCk)
Ok, my bad... I was just looking at it as the functional notation was in question.

So functional notation requires a simple-type-specifier, signed int is a simple-type-specifier however to help the compiler you would have to put it in parenthesis or just use signed.
1
2
(signed int)(myDouble);
signed (myDouble);
signed int is a simple-type-specifier

No it isn't, see http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/d91b5c8517c7d6f0?pli=1

As for casts in general, A(arg) is the same as static_cast<A>(arg) where valid, while (A)arg is the dreaded C-cast (personally, I am not for banishing it: things like std::addressof written without C casts are a pain to read)
Last edited on
closed account (1vRz3TCk)
Ok, So I consider a valid combinations of simple-type-specifiers to still be a simple-type-specifier but am willing to concede that someone on the standards committee says it is a combination of simple type specifiers, and is not itself a simple type specifier.
One could argue that the whole reason C casts have brackets around them is to avoid the whole mess of signed int(x).
Another question: When you do (type)(expression) is it equivalent to (type)expression or type(expression)?
The latter. expression may contain operators of lower precedence than the cast.
Topic archived. No new replies allowed.
Pages: 1... 345