Is there a reason to use

cout << static_cast<int>(thing);

instead of

cout << (int)thing;

?

Thanks,
Dave

static_cast is designed to painful, which encourages you to avoid casting when you might otherwise say "why not?". Another reason I've heard is that it's easier to search for a cast, while the (type) pattern is also seen in non-cast syntax. I have yet to see a case where I've wanted to search for a cast, and I work with C++ syntax parsers. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.