What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
class B { int val;
public:
B(int v=0):val(v){}
int getV() const {return val;} };
ostream & operator <<(ostream & out, const B & v) { out< template ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out< int main() { B t1[]={3,2,4,1,5}; B t2[]={6,10,8,7,9}; vector v1(5); transform(t1,t1+5,t2,v1.rbegin(), plus()); for_each(v1.rbegin(), v1.rend(), Out return 0; } Program outputs:
Suggested Answer: E
Get Premium CPP Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
7 comments · newest first
TA
Tanja
11 months ago
I agree, it should output 14 8 12 12 9!
BL
Blondell
12 months ago
Definitely not a compilation error.
RO
Ronny
12 months ago
Wait, how does plus() even work here?
NU
Nu
12 months ago
I think the output will be 14 8 12 12 9.
GE
Gerald
1 year ago
Looks like it should compile fine.
RO
Rose
1 year ago
Definitely escalating privileges. That's the key to expanding the attacker's foothold on the network. I feel confident about this one.
CA
Carri
1 year ago
I'm feeling pretty confident about this one. Asset depreciation is all about the decline in value of an asset over time, so the time element is definitely a key part of it. I think the answer has to be B, time value of money.