0

I can see everywhere that the standard for converting, for example, from char to int in C++ is

(int) 'a' 

But could I also do this conversion like in python i.e.

int ('a')

? To be clear, it works. I'm just asking if you can do that.

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
  • 1
    Yes, you can. It's called a "function-style cast" and there are other questions/answers on Stack Overflow that discuss it's merits (or otherwise) in some detail. – Adrian Mole Jul 02 '21 at 21:07
  • Related, that's a C-style cast. As in, what the C language uses. Not recommended in C++. – Drew Dormann Jul 02 '21 at 21:07

0 Answers0