int p = 1.0;the C++ compiler may complain:
warning: converting to `int' from `double'While in this case there is no loss of accuracy, in other cases there is:
int p = 1.5; // p gets value 1 -- no rounding is doneYou can deliberately convert a value from one type to another by casting it, like this:
int p = (int) 1.5;Now the compiler warning will not be given.
You can also use a more appropriate type:
double p = 1.5;
Now there are no type casts and no warnings.