declaring a variable with two types

  • A+

I'm a c++ beginner, and is reading Bjarne Stroustrup's Programming_ Principles and Practice Using C++.

In the section on 3.9.2 Unsafe conversions, the author mentioned

declaring a variable with two types

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 language I'm relatively familiar with). Is this a typo or a valid c++ syntax?


It's a mistake in the book. That is not a valid C++ declaration, even without the supposed narrowing conversion.

It isn't mentioned in any of the erratas on Bjarne Stroustrup's page(4th edition and earlier), though, which is odd. It's a clear enough mistake. I imagine since it's commented with //error few people fixate on the mistake in the declaration itself.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: