The old style cast was replaced by four distinct kinds of cast in C++ is because you can never be sure what the old style cast is doing. The four distinct kinds of cast in C++ allow you to say what kind of cast you want and allows the compiler to check that the cast is allowed.
The catch of course is that using the latter syntax, the compiler will do whatever it takes to make the cast happen if it is at all possible. However; in C++ you usually don't want this. Hence the new cast syntax.
From what I've learned/been told, you never really want the compiler to do anything implicitly. If you can make it explicit, do it. I'm sure this is debatable, but it's what I do
it mean that both way are different? but how come it give same result?
By definition, the C-style cast such as (int)d; tells the C++ compiler to consider, in this order:
a const_cast
a static_cast
a static_cast followed by a const_cast,
a reinterpret_cast
a reinterpret_cast followed by a const_cast
In your case, const_cast<int>(d) is invalid C++, so the compiler does not attempt that. Then it looks atstatic_cast<int>(d). That is valid C++, so the compiler produces the machine code for static_cast<int>(d), which is the same as if you'd have used static_cast<int>(d) directly.