Summer Special Limited Time 60% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 8w52ceb345

What happens when you attempt to compile and run the following code?

What happens when you attempt to compile and run the following code?

#include

#include

#include

#include

#include

using namespace std;

class compare {

bool reverse;

public:

compare(bool revparam = false){ reverse = revparam;}

bool operator()(int lhs, int rhs) const{

if (reverse)return (lhs > rhs);

elsereturn (lhs < rhs);

}

};

int main(){

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

priority_queue > first(myints, myints + 10);

priority_queue, compare> second(myints, myints + 10,

compare(false));

while (first.size() > 0){

cout << first.top() << " "; first.pop();

}

while (second.size() > 0) {

cout << second.top() << " ";second.pop();

}

return 0;

}

A.

compilation error

B.

program outputs: 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0

C.

program outputs: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9

D.

program outputs: 3 4 2 1 6 5 7 9 8 0 3 4 2 1 6 5 7 9 8 0

CPP PDF/Engine
  • Printable Format
  • Value of Money
  • 100% Pass Assurance
  • Verified Answers
  • Researched by Industry Experts
  • Based on Real Exams Scenarios
  • 100% Real Questions
buy now CPP pdf
Get 60% Discount on All Products, Use Coupon: "8w52ceb345"