Thread: typecasting

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You're an idiot. Typecasting is not "to be avoided". How would you assign a floating point number to an integer? Without a cast? Why? Why wouldn't you typecast it? What in your great wisdom makes the cast something to avoid there?

    What you mentioned above, typing with alt + number pad, has nothing to do with typecasting. Typecasting isn't something you punch in on your keyboard, unless you count the actual typing of the word "static_cast", or one of the others, or wrapping parenthesis around the keyword "int" or what not.

    In short, you're an idiot. The faster people figure this out, the less they'll be confused by your 'insight'.


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #2
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Code:
    for(int i = 0; i < 255; i++)
    {
      cout << i << " " << char(i) << endl;
    }
    //displays the number and the coresponding character
    //Pressing ALT and the number youll get hte character for example:
    //ALT 253 = ²
    //So STFU
    //idk if you read the book The C++ programming language - Bjarne Stroustrup,
    // but he clearly states that typecasting is to be avoied
    
    float afl = 2.48;
    int aInt = afl;
    //The Compiler may complain about it but
    //works perfectly and will give the exact same result as would:
    float afl = 2.48;
    int aInt = int (afl);
    What a ..........
    My Website
    010000110010101100101011
    Add Color To Your Code!

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by mrafcho001
    //Pressing ALT and the number youll get hte character for example:
    //ALT 253 = ²
    //So STFU
    This has absolutely nothing to do with typecasting. Getting input from the user is not typecasting.


    Quote Originally Posted by mrafcho001
    //idk if you read the book The C++ programming language - Bjarne Stroustrup,
    // but he clearly states that typecasting is to be avoied
    Page 14 - Notes to the reader
    Try to avoid void *, pointer arithmetic, unions and casts except deep within the implementation of some function or class. In most cases a cast is an indication of design error.


    Is that what you were looking for? Good for him. That doesn't make you any less of an idiot. As a matter of fact...
    Quote Originally Posted by mrafcho001
    float afl = 2.48;
    int aInt = afl;
    //The Compiler may complain about it but
    //works perfectly and will give the exact same result as would:
    float afl = 2.48;
    int aInt = int (afl);
    [/code]What a ..........
    If he agrees with you, that it's better to just let your compiler spit warnings at you, and to do nothing about them, when you can get rid of them with a cast, then he's an idiot too.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    You know i can stay here all day and argue with your, but im gonna be the man and walk away from this .........

    Peace out dude, and just a side note, if you have problems with what others post just say what you think/know is right, you don't have to be a .......... about everything.
    My Website
    010000110010101100101011
    Add Color To Your Code!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer Arithmetic and Typecasting
    By pobri19 in forum C Programming
    Replies: 2
    Last Post: 03-19-2009, 11:06 PM
  2. recv() typecasting error
    By jmd15 in forum Networking/Device Communication
    Replies: 7
    Last Post: 05-19-2006, 03:32 PM
  3. c and c++ style typecasting confusion
    By vaibhav in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2005, 07:29 AM
  4. Typecasting a void* to a function pointer
    By Procyon in forum C++ Programming
    Replies: 2
    Last Post: 01-14-2004, 05:43 PM
  5. typecasting
    By JaWiB in forum C++ Programming
    Replies: 14
    Last Post: 06-01-2003, 10:42 PM