I'm writing a simple C++ program using an example from the book: Programming principles and practice using C++.But I can not understand a thing, my book told me that the sqrt() function applies only to objects of type double, so in my program I first read an integer value then i should assign it to double and use the sqrt function.
cout << "Please enter a floating-point value\n";
int n;
cin >> n; // read a double from the keyboard into n
cout << "n == " << n
<< "\nn+1 == " << n + 1
<< "\nthree times == " << 3 * n
<< "\ntwice n == " << n + n
<< "\nn squared == " << n * n
<< "\nhalf of n == " << n / 2
<< "\nsquare root of n == " << sqrt(n)
<< '\n';
So I tried to use the sqrt function on an object of type int, and my compiler did not report any error, why?