![]() |
| ||
| Problem converting to a double I'm trying this: char info[50]; myfile.getline(info, sizeof(info) ); double my_double = atof(info); It seems to work, I think, but I'm getting an error when I try to print out the double. It says no matching function for ostream& << &double. Can anyone help me with this? |
| ||
| Re: Problem converting to a double Sorry, it seemed to be a problem with something else. I fixed it, but it's not recognized my class that should have been imported: I included the file: #include "Card.h" Which is a debitcard class that has some methods. I tried calling one of those methods and it says "implicit declaration of int set_balance(..)" I called it like this: set_balance(my_double); That is the signature of the method. Is there something I'm not doing? |
| ||
| Re: Problem converting to a double Can you provide more code? (Also, calling atof for a double maybe a bad idea - losing precision/etc). |
| ||
| Re: Problem converting to a double >Also, calling atof for a double maybe a bad idea - losing precision/etc Calling atof may indeed be a bad idea, but not for the reason you stated. atof returns a double, so the only loss of precision would come from the converted string not representing a value that a double can handle. You should think of the f in atof as "floating-point", not "float". >set_balance(my_double); Okay, you're saying that your class isn't recognized, and that the above quote is how you call the member function (aka. method) of the class. So where is the object that you call the member function on? You know, <object>.<member function>(args)? It looks more like you're calling a non-member function, and obviously the compiler won't find it. |
| ||
| Re: Problem converting to a double Quote:
|
| All times are GMT -4. The time now is 2:36 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC