Casting issue ( warning C4244 )

Hi,

this function below when called gets a value (count) in order to find the right place in the array of doubles (heats) and return that double value. However, when returning, the value is converted from a double to an int.

int Runner::getRuns(int count)
{
return this->heats[count];
}

I have tried to cast it differently, both using

static_cast<DataType>(Value)

as well as prefix notation, but the conversion persists.

Can anyone show me a way to make the double value remain a double when getting passed back to the calling, i e how to avoid the conversion? And why does the conversion occur at all?



I may be misunderstanding but wouldn't

1
2
3
4
double Runner::getRuns(int count)
{
return this->heats[count];
}


do what you want?

Also if heats[] is part of your Runner class, you can just return heats[count] without the this-> bit.
Last edited on
LOL, hilarious,

thanks a whole lot Moooce, that fixed it,

and the misunderstanding is completely on my side.

Needless to say, I am kind of noob still...

:D

Best,

J
yeah, no probs, and I bet you'll not make that mistake again :-)
Haha, nope
Topic archived. No new replies allowed.