Given a text file with the image of integers that must be rewritten in the queue Qu1. In the Qu2 queue, first write the numbers of palindromes, then the numbers, the sum of the digits of which is odd, the remaining numbers to write to the output file. Create a program using OOP methods.
I did what I could, but there were a lot of mistakes ... I ask for your help!
#include "stdafx.h" #include <iostream> #include <conio.h> #include <queue> #include <fstream> #include <algorithm> #include <iterator> using namespace std; unsigned getReverse(unsigned n) { unsigned r = n % 10; while (n /= 10) { r = r * 10 + n % 10; } return r; } bool isPalindrom(const unsigned n) { return n == getReverse(n); } class cQueue { protected: queue<int> p_; public: void IO(); void Del() { while (!p_.empty()) { p_.pop(); } }; }; void cQueue::IO() { ifstream ifile("text.txt"); ofstream ofile("output.txt", ios::trunc); queue<int> qu1 = p_; for_each(istream_iterator<int>(ifile), istream_iterator<int>(), [&qu1](int n) { qu1.push(n); }); cout << "Number of items in the queue: " << qu1.size() << endl; while (!qu1.empty()) { cout << "\nHere they are: " << qu1.front() << '\n'; } queue<int> qu2; copy_if(queue<int>(qu1), queue<int>(), queue<int>(qu2), [&qu1](int n) -> bool { if (isPalindrom(n)) { return n; } else if (n) { // Сумма нечетных чисел ? } else { // В выходной файл ? } }); cout << "Number of items in the queue: " << qu2.size() << endl; while (!qu2.empty()) { cout << "\nHere they are: " << qu2.front() << '\n'; } } int main() { cout << "Demo Queue OOP" << endl; cQueue queue; queue.IO(); cout << endl; queue.Del(); _getch(); return 0; } Error C2675 unary "++": "std :: queue >>" does not define this operator or type conversion is acceptable to the built-in operator \ algorithm 594
C2100 error invalid indirect reference \ algorithm 596
Error C2100 invalid indirect reference \ algorithm 598
Error C2675 unary "++": "std :: queue >>" does not define this operator or type conversion is acceptable to the built-in operator \ algorithm 599
Error C4996 'std :: copy_if :: _ Unchecked_iterators :: _ Deprecate': Call to 'std :: copy_if' To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. Visual C ++ 'Checked Iterators' \ algorithm 589
copy_if(...)- MiT