Thread: Implicit and Explicit

  1. #1
    Veni Vidi Vice
    Join Date
    Aug 2001

    Implicit and Explicit

    Iīm reading a c++ book here and it seems that the words implicit and explicit occurs very frequently. The problem is that I donīt know what it means.
    I have seen it in differnent context such as "we look at the issue of both implicit and explicit type conversion" and "a member function defined outside
    the class must explicitly declare itself to be inline". I think it has something to do that sometimes you write extra-code when you really don't need to
    do it like

    int number = int(7); //unnecessary
    float fnumber = 1234567.1234567f //also unnecessary
    but that is only a Theory. What does it actually mean???

  2. #2
    Registered User mepaco's Avatar
    Join Date
    Aug 2002
    Implicit can be taken as implied, but explicit means that you state it must be done yourself. Like with casts. Here is an implicit cast:

    int implicit;
    implicit = 7.5;

    The value '7.5' will implicitly be cast as an int. This means the compiler does it for you.

    Here is explicit:

    int explicit;
    explicit = (int)7.5;

    Here you tell the compiler that you want it cast. You explicitly declare the conversion. Hope that helps.

  3. #3
    Veni Vidi Vice
    Join Date
    Aug 2001
    Perfect clear!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Overload the..bool operator..?
    By 39ster in forum C++ Programming
    Replies: 18
    Last Post: 11-26-2008, 06:24 AM
  2. Replies: 12
    Last Post: 02-12-2008, 05:05 PM
  3. Replies: 6
    Last Post: 08-12-2007, 01:02 PM
  4. Explicit keyword
    By Mario F. in forum C++ Programming
    Replies: 5
    Last Post: 06-30-2006, 06:43 PM
  5. implicit explicit
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 01-22-2002, 04:10 AM