typecasting

This is a discussion on typecasting within the C++ Programming forums, part of the General Programming Boards category; I was reading through the tutorial on this site and came to the typecasting tutorial, and i was just wondering ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    176

    typecasting

    I was reading through the tutorial on this site and came to the typecasting tutorial, and i was just wondering what anyone would ever need typecasting for

  2. #2
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483

    You can see all the ASCII characters by typecasting and then press ALT and the number on the number pad and get the desired effect

    and other things, typecasting is to be avoided
    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

    You can see all the ASCII characters by typecasting and then press ALT and the number on the number pad and get the desired effect

    and other things, typecasting is to be avoided
    Do you just like to talk out your ass or what? Nearly ever post of yours I've come across is full of gems like these.


    Typecasting is used to convert one type of an object to another. For example, if you have a floating point number, and you wan't to treat it as an integer, you may type cast it. The language itself has automatic type promotion for the basic types: char to short int to int to long int, float to double, and the like. Typecasting is used for when there are no such conversions and you need one.


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

  4. #4
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    whats your problem?

    Typecasting can be used for the reason i pointed above... and it is to be avoided, there is like nothing wrong with what i said..
    My Website
    010000110010101100101011
    Add Color To Your Code!

  5. #5
    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.

  6. #6
    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!

  7. #7
    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.

  8. #8
    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-20-2009, 12:06 AM
  2. recv() typecasting error
    By jmd15 in forum Networking/Device Communication
    Replies: 7
    Last Post: 05-19-2006, 04:32 PM
  3. c and c++ style typecasting confusion
    By vaibhav in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2005, 08: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, 11:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21