C++ Institute C++ Certified Professional Programmer CPP Question # 13 Topic 2 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 13 Topic 2 Discussion

CPP Exam Topic 2 Question 13 Discussion:
Question #: 13
Topic #: 2

What happens when you attempt to compile and run the following code? Choose all that apply.

#include

#include

#include

#include

#include <algorithm>

#include

using namespace std;

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) {out<

int main () {

int t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

fstream f("test.out", ios::trunc|ios::out);

list l(t, t+10);

for_each(l.begin(), l.end(), Out(f));

f.close(); f.open("test.out");

for( ; f.good() ; ) {

int i; f>>i;

cout<

}

f.close();

return 0;

}


A.

file test.out will be opened writing


B.

file test.out will be truncated


C.

file test.out will be opened for reading


D.

no file will be created nor opened


E.

program will display sequence 1 2 3 4 5 6 7 8 9 10


Get Premium CPP Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.