Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute Exam CPP Topic 3 Question 64 Discussion

Actual exam question for C++ Institute's CPP exam
Question #: 64
Topic #: 3
[All CPP Questions]

Which method added to class B at the marked spot will allow the code below to compile? Choose

all possible solutions.

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v):val(v){}

int getV() const {return val;}

/* Insert Code Here */

};

ostream & operator <<(ostream & out, const B & v) { out<

templatestruct Out {

ostream & out;

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

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

int main() {

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

vector v1(t, t+10);

sort(v1.begin(), v1.end(), greater());

for_each(v1.begin(), v1.end(), Out(cout));cout<

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Kerry
2 days ago
I see your point, but I still think A is the best choice because it compares the values correctly.
upvoted 0 times
...
Carey
8 days ago
I disagree, I believe the correct answer is C.
upvoted 0 times
...
Kerry
14 days ago
I think the answer is A.
upvoted 0 times
...