lundi 29 mars 2021

C++: how to redefine getline() when using two overloads of it?

I need to use two types of getline in my program.
First:

template<> std::istream &std::getline<char, std::char_traits<char>, std::allocator<char>>(std::istream &__is, std::__cxx11::string &__str, char __delim)
+4 overloads

Read a line from an rvalue stream into a string.

which I use for In a while condition.

getline(strstrm, field,',')

where:

string line, field, temp;
stringstream strstrm(line);

But now When I try to use this getline:

getline(rowTemp, lineTemp);

I get a error. Here:

string lineTemp, wordTemp;
vector<string> rowTemp;

I have added the statement:

using namespace std;

I am using the following header files

#include<iostream>
#include<string>
#include<limits>
#include<fstream>
#include<iomanip>
#include<conio.h>
#include<vector>
#include<algorithm>

My error is

getline
+6 overloads

Read a line from stream into a string.

Parameters:
__is – Input stream.
__str – Buffer to store into.

Returns:
Reference to the input stream. Stores characters from is into __str until '

no instance of overloaded function "getline" matches the argument list -- argument types are: (std::vector<std::__cxx11::string, std::allocator<std::__cxx11::string>>, std::__cxx11::string)C/C++(304)

My entire code can be seen Here

I am kind of new to the c++. I would appreciate if someone could point me in the correct direction. Thank You.

Aucun commentaire:

Enregistrer un commentaire