What will happen when you attempt to compile and run the code below, assuming that file test.in contains the following sequence: 1 2 3?#include <iostream>#include <fstream>#include <string>#include <list>#include <algorithm>using namespace std;template<class T>struct Out {ostream & out;Out(ostream & o): out(o){}void operator() (const T & val ) {out<<val<<" "; } }; int main () { ifstream f("test.in"); list<int> l; for( ; !f.fail() ; ) { int i; f>>i; l.push_back(i);}f.close();for_each(l.begin(), l.end(), Out<int>(cout));return 0;}Programwill output:
A. 1 2 3
B. 1 2 3 3
C. no output
D. compilation error E. program runs forever without output
What will happen when you attempt to compile and run the code below, assuming that file test.in contains the following s
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What will happen when you attempt to compile and run the code below, assuming that file test.in contains the following s
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!