c++ getline() error, no instance of overload function "getline" matches the argument list

user2924752

I am getting the following error when using a getline() function:

no instance of overload function "getline" matches the argument list

In one class named "Time" I use it when reading in the following input:

istream & operator >> (istream & input, Time & C) /// An input stream for the hour     minutes and seconds
{
char ch;
input >> C.hour >> ch >> C.minute >> ch >> C.second;
getline(input,C.ampm,',');

return input;   /// Returning the input value
}

This works fine, but I also want to use it for another class called "Shares":

istream & operator >> (istream & input, Shares & C) /// An input stream for the day, month and year
{
char ch;
input >> C.price >> ch >> C.volume >> ch >> C.value >> ch;
getline(input,C.value,',');

return input;   /// Returning the input value
}

However, the getline function in the "shares" class is giving me the error. Both classes are using the libraries:

#include <iostream>
#include <string>

How can I overcome this? Thanks

lpapp

getline(input,C.value,',');

based on the comments, you wrote that C.value is double. That will not fly because as others pointed out, the expected parameter is a string type in there.

You would need to read into a temporary string and then convert it to your double. The latter step is simple, but even simpler with C++11's std::stod.

Therefore, you would be writing something like this:

std::string valueString;
getline(input, valueString, ',');
C.value = std::stod(valueString);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why am I having trouble with getline()? "No instance of overloaded functions matches the argument list" and "data is ambiguous"

No instance of overloaded function matches the argument list

How to fix an "no instance of constructor matches argument list" error in C++?

C++ more than one instance of overloaded function matches the argument list when creating a header file

c++ template - More than one instance of overloaded function matches the argument list

C++ and SFML, no instance of the overloaded function "sf::RenderWindow.draw()" matches the argument list

More than one instance of overloaded function matches the argument list and I can't find where the error happens

c++ struct in map as value - error "no instance of overloaded function matches the argument list"

no matching function for getline c++

Error with getline

Valgrind-Uninitialised value error with getline() function

Writing getline function in c language

Using GetLine with ifstream - no instance of "getline" matches the argument list

C++ 11 multi-thread merge sort with error “no instance of contructor 'std::thread' matches the argument list”

C++ Getline issues (No instance of overloaded function "getline"

No instance of overloaded function for getline

CUDA template error: no instance of function template matches the argument list

Segmentation error with getline() function?

namespace error in using getline() function in main()

How to fix "no instance of overloaded function "getline" matches the argument list" when using getline with an int

Error E0289: No instance of constructor "Movie::Movie" matches the argument list for a Basic Program (C++)

How can I fix a "no instance of function template 'Defer' matches the argument list" error in C++?

Error No instance of overloaded function "getline" matches the argument list

no instance of "getline" matches the argument list

getline() not taking delimiter argument (ERROR: no instane of overloaded function "getline" matches argument list

Error passing Eigen matrix to a function in C++: "no instance of overloaded function matches the argument list"

C getline() function: return value vs second argument

C++ No instance of overloaded function matches the argument list when calling std::replace()

C++ no instance of function template matches the argument list