Results 1 to 6 of 6

Thread: Difference between Implicit & Explicit type conversions

  1. #1
    Join Date
    Dec 2009
    Posts
    41

    Difference between Implicit & Explicit type conversions

    Hello friend,

    I am totally confused about the Implicit & Explicit type conversions. I am not able to find out the exact difference between these two conversion types. According to my knowledge it is related to the something like type casting operation. Do you any difference between Implicit & Explicit type conversions? If yes then please let me know the same. I would appreciate you help over this.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Difference between Implicit & Explicit type conversions

    'Implicit type conversions' commonly referred to implicit conversions that preserve the values in the name of promotion. Before performing an arithmetic operation, using a full promotion to create int from shorter integer types. Note that these promotions are not going to promote a long type. This reflects the original objective of these promotions in C for giving a size operands "natural" for arithmetic operations.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Difference between Implicit & Explicit type conversions

    An integer can be converted to another type of integers and this is the simple example of 'Implicit type conversion'. You can convert an enumeration value to an integer type. If the recipient type is unsigned, the value will contain as many bits of the source can receive the destination (the bits are abandoned if necessary). More precisely, the result is the smallest unsigned integer according to the source of rank 2 module n, where n is the number of bits used to represent the unsigned type.

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Difference between Implicit & Explicit type conversions

    Please refer following example of Explicit Type Conversion:
    Code:
    #include <iostream>
    using namespace std;
    class Point1
    {
    public:
        
        Point1() { xd = yd = 0; }
        Point1( int Xk, int Yk ) { xd = Xk; yd = Yk; }
        unsigned& x() { return xd; }
        unsigned& y() { return yd; }
        void Show()   { cout << "xk = " << xd << ", "
                             << "yk = " << yd << "\n"; }
    private:
        unsigned xd;
        unsigned yd;
    };
    
    int main()
    {
        Point1 Point10, Point20;
        Point10 = Point( 100, 100 );
        Point10.x() = unsigned( 200 );
        Point10.Show();
        Point20 = Point1();
        Point20.Show();
    }

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Difference between Implicit & Explicit type conversions

    Hi,

    The following conversion comes into the Implicit type conversion:
    1. Floating point conversions to Boolean, character or integer
    2. Conversions of pointers and references
    3. Conversions to floating-point type
    4. Conversions to the types Boolean, integer and character

  6. #6
    Join Date
    May 2008
    Posts
    2,389

    Re: Difference between Implicit & Explicit type conversions

    Hello friend,

    Explicit type conversion is nothing but the conversion which explicitly defined in a program. A floating point value can be converted to another type float. If the source value may be represented in exactly the type recipient, the result is the original numerical value. If the source value is between two values adjacent recipients, the result is one of those values. Any pointer to an object type can be implicitly converted to a void *.

Similar Threads

  1. Replies: 4
    Last Post: 02-01-2011, 12:25 AM
  2. Meaning of Explicit and Implicit Conversion
    By Sheenas in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 12:42 PM
  3. Difference between the different type of Cores
    By ramkmpaa2 in forum Motherboard Processor & RAM
    Replies: 2
    Last Post: 26-11-2009, 05:28 PM
  4. Replies: 3
    Last Post: 30-10-2009, 06:27 PM
  5. Difference between Implicit and Explicit Declaration
    By vinodpathak_214 in forum Software Development
    Replies: 3
    Last Post: 16-01-2009, 10:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,897,789.44691 seconds with 17 queries