-
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
Code:
int number = int(7); //unnecessary
float fnumber = 1234567.1234567f //also unnecessary
but that is only a Theory. What does it actually mean???
-
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.
-