How to prevent floating-point being implicitly converted to integral value at function call?
#include <iostream>
void fn(int x) {
std::cout<<"fn("<<x<<")\n";
}
int main() {
std::cout<<"Hello, this is 301014 :)\n";
fn(2);
fn(3.5);
return 0;
}
Here the outputs are 2 and 3 respectively.
I am compiling with g++ -std=c++11 31014.cpp -o 31014 -v
. And there is no mention of 3.5 being converted to 3.
Is there a way to prevent, or atleast detect, this?
Kindly help me out, please.