Thread: Implicit Cast Bad Practice ?

  1. #1
    Banned
    Join Date
    Jul 2022
    Posts
    112

    Implicit Cast Bad Practice ?

    Are Implicit conversion problematic ?

    Code:
    int i = 2;
    char s = i;
    
    long long x = 2;
    float f = x;
    Last edited by kodax; 3 Weeks Ago at 06:40 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,322
    Quote Originally Posted by kodax View Post
    Are Implicit conversion problematic ?

    Code:
    int i = 2;
    char s = i;
    
    long long x = 2;
    float f = x;
    Yes (they can be).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Banned
    Join Date
    Jul 2022
    Posts
    112
    What about those people who cast malloc ?

  4. #4
    Banned
    Join Date
    Jul 2022
    Posts
    112
    This is a simple question, but a good one..

    At some point, when you look back,
    there's always the "what if",
    even if you avoid it.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,322
    Quote Originally Posted by kodax View Post
    What about those people who cast malloc ?
    If they've got a good arm, maybe they can make it as a quarterback.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Banned
    Join Date
    Jul 2022
    Posts
    112
    The one who is great is immense, therefore he is feared by the masses.
    How can one who is formidable and mighty not arise..

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,322
    Quote Originally Posted by kodax View Post
    The one who is great is immense, therefore he is feared by the masses.
    How can one who is formidable and mighty not arise..
    You forgot to add yeast to the dough.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Implicit cast to const
    By Martin Kalbfuß in forum C Programming
    Replies: 2
    Last Post: 03-16-2011, 04:36 PM
  2. Implicit declaration
    By JFonseka in forum C Programming
    Replies: 4
    Last Post: 11-27-2007, 07:35 AM
  3. implicit declarations
    By caroundw5h in forum C Programming
    Replies: 5
    Last Post: 03-27-2004, 08:16 PM
  4. Implicit Constructor
    By Blanket in forum C++ Programming
    Replies: 16
    Last Post: 04-23-2003, 09:34 PM
  5. reinterpret_cast, C-style cast or function-style cast
    By blight2c in forum C++ Programming
    Replies: 3
    Last Post: 05-14-2002, 10:07 PM

Tags for this Thread