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?

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?

Can you provide more code? (Also, calling atof for a double maybe a bad idea - losing precision/etc).

>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.

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 thought the same thing, but the paper I'm reading from said all I have to do is #include the class and call the method (and the method was in a class). I didn't think that would work, and indeed it didn't. Oh well, I'll create the object like I should have in the first place. Thanks for clearing that up. I'm glad you did, because I was really getting confused with the paper saying/showing I didn't need an object.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.