About 1,990,000 results
Open links in new tab
  1. Python: typing.cast vs built in casting - Stack Overflow

    Jan 4, 2023 · 23 str(x) returns a new str object, independent of the original int. It's only an example of "casting" in a very loose sense (and one I don't think is useful, at least in the …

  2. c# - Direct casting vs 'as' operator? - Stack Overflow

    Sep 25, 2008 · Direct Casting Types don't have to be strictly related. It comes in all types of flavors. Custom implicit/explicit casting: Usually a new object is created. Value Type Implicit: …

  3. Casting objects in Java - Stack Overflow

    Mar 15, 2011 · Casting can be used to clearly state that you are calling a child method and not a parent method. So in this case it's always a downcast or more correctly, a narrowing conversion.

  4. Regular cast vs. static_cast vs. dynamic_cast - Stack Overflow

    Aug 26, 2008 · Static cast is also used to cast pointers to related types, for example casting void* to the appropriate type. dynamic_cast Dynamic cast is used to convert pointers and references …

  5. Best practice in C++ for casting between number types

    May 28, 2016 · What is the best practice for casting between the different number types? Types float, double, int are the ones I use the most in C++. An example of the options where f is a …

  6. What are the rules for casting pointers in C? - Stack Overflow

    Jun 23, 2013 · There are rules about casting pointers, a number of which are in clause 6.3.2.3 of the C 2011 standard. Among other things, pointers to objects may be cast to other pointers to …

  7. casting - Explanation of ClassCastException in Java - Stack Overflow

    May 25, 2009 · Do you understand the concept of casting? Casting is the process of type conversion, which is in Java very common because its a statically typed language. Some …

  8. Need some clarification regarding casting in C - Stack Overflow

    Dec 22, 2009 · There are several situations that require perfectly valid casting in C. Beware of sweeping assertions like "casting is always bad design", since they are obviously and patently …

  9. casting - How to cast int to enum in C++? - Stack Overflow

    May 28, 2017 · How do I cast an int to an enum in C++? For example: enum Test { A, B }; int a = 1; How do I convert a to type Test::A?

  10. casting - Downcasting in Java - Stack Overflow

    Dec 19, 2008 · Upcasting is allowed in Java, however downcasting gives a compile error. The compile error can be removed by adding a cast but would anyway break at the runtime. In ...