C++ Institute C++ Certified Professional Programmer CPP Question # 8 Topic 1 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 8 Topic 1 Discussion

CPP Exam Topic 1 Question 8 Discussion:
Question #: 8
Topic #: 1

Which pieces of code inserted independently into places marked 1 and 2 will cause the program to compile and display: 0 1 2 3 4 5 6 7 8 9? Choose all that apply.

#include

#include

using namespace std;

class A { int a; public:

A(int a){ this?>a=a;}

//insert code here 1

};

//insert code here 2

template void print(T start, T end) {

while (start != end) {

std::cout << *start << " "; start++;

}

}

int main() {

A t1[] ={ 1, 7, 8, 4, 5 };list l1(t1, t1 + 5);

A t2[] ={ 3, 2, 6, 9, 0 };list l2(t2, t2 + 5);

l1.sort();l2.sort();l1.merge(l2);

print(l1.begin(), l1.end());

print(l2.begin(), l2.end()); cout<

return 0;

}


A.

place 1: operator int() { return a; }


B.

place 1: operator int() { return a; }

bool operator < (const A & b) { return this?>a< b.a;}


C.

place 1: bool operator < (const A & b) { return this?>a< b.a;}


D.

place 1: bool operator < (const A & b) { return this?>a< b.a;}

friend ostream & operator <<(ostream & c, const A & a);

place 2: ostream & operator <<(ostream & c, const A & a) { c<<a.a; return c;}


E.

place 1: bool operator < (const A & b) { return this?>a< b.a;}

place 2: ostream & operator <<(ostream & c, const A & a) { c<<a.a; return c;}


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.