| | |
Problem converting to a double
![]() |
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
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?
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?
>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.
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.
I'm here to prove you wrong.
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
•
•
•
•
Originally Posted by Narue
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.
![]() |
Similar Threads
- Weird problem with float or double.... (Python)
- converting double to string (Java)
- Math problem in C (C)
- cannot convert from 'double' to 'float [6][3]' (C)
Other Threads in the C Forum
- Previous Thread: (C) have 2 parse errors (help)
- Next Thread: Serialize/MFC Question
| Thread Tools | Search this Thread |
* adobe api array asterisks binarysearch calculate changingto char character cm copyanyfile copyimagefile copypdffile creafecopyofanytypeoffileinc createcopyoffile createprocess() csyntax database directory feet fgets file floatingpointvalidation forloop frequency function givemetehcodez global grade gtkgcurlcompiling gtkwinlinux hacking highest histogram homework i/o infiniteloop input interest intmain() iso kernel keyboard kilometer km linked linkedlist linux looping loopinsideloop. lowest meter microsoft mqqueue mysql number oddnumber odf open openwebfoundation owf pdf performance posix power probleminc process programming pyramidusingturboccodes radix read recv recvblocked repetition research reversing scheduling segmentationfault send sequential single socket socketprogramming stack standard string suggestions systemcall threads turboc unix urboc user variable wab whythiscodecausesegmentationfault win32api windows.h windowsapi






