The following class takes a string
line as input from the user. My aim is to store it in the istringstream iss
and then to extract various data from the istringstream iss
into various variables. But, when I try to initialize iss
with string user_input
, I am getting this error when I compile the file:
error C2064: term does not evaluate to a function taking 1 arguments
I think the problem is in the line iss{user_input};
Please explain why I am getting this error.
_input.h
header file
#pragma once
#include <string>
#include<sstream>
#include "_date.h"
#include "_time.h"
using namespace std;
//definition of class input
class _input
{
string user_input;
istringstream iss;
//datamembers to be sent
int esno,eday, emonth, eihours, eimins, eohours, eomins, emo;
char eiap, eoap;
string enotes;
public:
_input();
void get_input();
void process_data();
};
_input.cpp
file
#include "_input.h"
_input::_input() : user_input { "Nothing Entered" }, iss{ "" }, esno{ 0 }, eday{ 0 }, emonth{ 0 },
eihours{ 0 }, eimins{ 0 }, eohours{ 0 }, eomins{ 0 }, emo{ 0 }, eiap{ 'n' }, eoap{ 'n' }, enotes{ "" }
{
}
void _input::get_input() // to store in iss
{
cout << "Enter the entry : Format (Date - In Time - Out Time - Money Owed - Notes)" << endl;
getline(cin, user_input);
iss{user_input}; //THIS IS WHERE I GET THE ERROR
}
void _input::process_data()
{
iss >> eday >> emonth >> eihours >> eimins >> eiap >> eohours >> eomins >> eoap >> emo >> enotes;
++esno;
}