Which pieces of code inserted independently into places marked 1 and 2 will cause the program to compile and display: 0

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Which pieces of code inserted independently into places marked 1 and 2 will cause the program to compile and display: 0

Post by answerhappygod »

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 <list>#include <iostream>using namespace std;class A { int a; public:A(int a){ this?>a=a;}//insert code here 1};//insert code here 2template<class T> void print(T start, T end) {while (start != end) {std::cout << *start << " "; start++;}}int main() {A t1[] ={ 1, 7, 8, 4, 5 };list<A> l1(t1, t1 + 5);A t2[] ={ 3, 2, 6, 9, 0 };list<A> l2(t2, t2 + 5);l1.sort();l2.sort();l1.merge(l2);print(l1.begin(), l1.end());print(l2.begin(), l2.end()); cout<<endl;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;}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!

This topic has 1 reply

You must be a registered member and logged in to view the replies in this topic.


Register Login
 
Post Reply