我需要将“用户定义的双端队列”数据写入文本文件。 Deque具有对象形式的数据。
我必须将m_clock
添加到双端队列,然后将数据写入txt文件。
我可以将m_clock
添加到双端队列。这是我的代码:
void classTB::SendInput(uint64_t m_clock)
{
ClassForCreatingDeque obj = user_define_queue.front();
obj.clock = m_clock;
user_define_queue_with_clock.push_back(obj);
ofstream f;
f.open("textfile.txt");
//std::string output_string = user_define_queue_with_clock.front();
//f << obj.m_clock;
//f.write((char*) & obj, sizeof(obj));
f.close();
}
//Tried this too:
deque<ClassForCreatingDeque>::iterator it;
for (it = user_define_queue_with_clock.begin();
it !=user_define_queue_with_clock.end(); ++it)
//cout << '\t' << *it;
f << *it;
// iterator is also throwing error as " no operator "<<" matches there
//oprand. Oprand type are std::ofstream << ClassForCreatingDeque