I need a some help with my homework.
I can not figure out why I am getting these errors 'double' to 'float' warnings and double to int starting at line 45 (in bold). I just do not see what is wrong.
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>
#include "win.h"
Just like guestgulkan says, when delta_y is initialized the compiler automatically assumes you want 0.0 to be a double and then thinks your trying to put it into a float
Ok, I see what your saying. So how do I fix that? I need to change the float to double then? I tried that. I change float to double went to compile and got this these errors. Why does it ant to change everything to int?
\main.cpp(45) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
main.cpp(45) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
main.cpp(45) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
\main.cpp(51) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
main.cpp(51) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
main.cpp(52) : error C2059: syntax error : '='
1>cannonball - 1 error(s), 5 warning(s)
if I do not change my float to double I always get
at line 50 warning C4244: '=' : conversion from 'double' to 'float', possible loss of data.
using the top down method of debugging my problem is at line 45 which is
Circle(Win, x_position, y_position, 10); I tried changing the 10 to 10.0. But I do not understand.
any and all help is welcome
The program is suppose to take the users entered Velocity and shoot a ball
You are getting confused. The compiler does not particularly 'want' to change anything, but sometimes it has to - when it is expecting one type of number and you are giving it another type. It will do the change(if it can) but it will warn you about possible data loss.
This is what it is telling you here.
The type of parameters values required by the Circle function are obviously integers - BUT YOU ARE PASSING IT DOUBLES.
When a double type is forced into an integer type, then the fraction part is lost - which means that data is lost. This is what the compiler warning is all about.
Do you understand the basic differences between, integers and floats and double types?
The problem is the declared types and what you want to do with them, your double userVelocity is being multiplied and crushed into your float delta_y, what you need to do is look over your code and make sure that no types get put into others.