I'm a C++ beginner, and I'm reading Bjarne Stroustrup's Programming: Principles and Practice Using C++.
In the section on 3.9.2 Unsafe conversions, the author mentioned
When the initializer is an integer literal, the compiler can check the actual value and accept values that do not imply narrowing:
int char b1 {1000}; // error: narrowing (assuming 8-bit chars)
I'm puzzled by this declaration. It uses two types (int
and char
). I have never seen such declaration in Java and Swift before (the two languages I'm relatively familiar with). Is this a typo or a valid C++ syntax?
float char
is another useful type, especially in swimming pools. Some come with a holder for a beer. – Latifundiumlong long
is a distinct datatype in C / C++. It is a 64 bit integer these days in practise, even on 32 bit platforms (the integer types are a bit of a mess generally, and there are now about 32767 of them because the standards guys keep making up new ones for no obvious reason). – Thinkable