I am trying to read time for an assignment. I am using the following code. It was working fine earlier, but now gives an error:
#include <iostream>
#include <string>
#include <ctime>
#include <vector>
#include <sstream>
using namespace std;
#define LOG(x) cout << x << endl
class Date
{
private:
string date;
string time;
string day;
string month;
string year;
string WeekylQuote;
public:
void TimeReadFromSystem(string &str) //this function read time of system
{
time_t my_time = time(NULL);
}
void StorerOfAscTimeIntoVariables(const string &str)
{
vector<string> strTok;
istringstream ss(str);
string deliminiters;
while (ss >> deliminiters)
{
strTok.push_back(deliminiters);
}
//for (auto i : strTok)
//cout << i << endl;
//OUTPUT
//Thu
//Apr
//22
//00:46:59
//2021
// storing now day month year in respective variables
date = (strTok[2]);
month = (strTok[1]);
year = (strTok[4]);
time = (strTok[3]);
day = (strTok[0]);
}
};
The error occurs on time(NULL)
:
type 'std::string' (aka 'basic_string') does not provide a call operator
I have also noticed if I create another .cpp
and just implement that function, it seems to work, but in the code I have written for my assignment it doesn't work.