I am new to c++ and I keep getting the c2668 error.
My assignment for the class is to change the program so that it compiles but not removing any statements, just use type casts to get rid of the warnings and errors. I have been spinning my wheels all weekend on this. Any thoughts?
My code is
#include <iostream> // for output functions
#include <cmath> // for math functions, sqrt and pow
using namespace std;
really?? im using visual studio 2005 set to warning level 2. i keep getting the c2668 error and the c4244 warning for the possible loss of data when i compile.
There are two pow/sqrt functions, one that takes a float and returns a float, and one that takes a double and returns a double. In the cast of your float/int, it doesn't know whether to cast it up to a double or just use the float function. Cast them to doubles and it should fix the issue.