CPP C++ Certified Professional Programmer

Loading demo links...

Showing 7–9 of 15 questions

Question 7 (Volume B)

Which lines of the code below contain proper instantiation of queue objects?

#include

#include

#include

#include #include

using namespace std;

int main()

{

deque mydeck; list mylist; vector myvector; queue first; // line I queue second(mydeck);// line II queue third(second);// line III queue fourth(mylist);// line IV queue fifth(myvector);// line V return 0; }

Select all that apply, then click Submit answer.

  • line I

  • line II

  • line III

  • line IV

  • line V

Question 8 (Volume A)

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):val(v){}

int getV() const {return val;} bool operator < (const B & v) const { return valstruct Out { ostream & out;

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

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

int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3}; deque d1(t, t+10); sort(d1.begin(), d1.end());

deque::iterator it = upper_bound(d1.begin(), d1.end(), B(4)); for_each(it, d1.end(), Out(cout)); cout<

Program outputs:

Select an option, then click Submit answer.

  • 5 6 7 8 9 10

  • 4 5 6 7 8 9 10

  • 6 7 8 9 10

  • 1 2 3 4 5

  • 1 2 3 4

Question 9 (Volume B)

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

#include #include

int main ()

{

std::vectorv1;

for(int i = 0; i<10; i++) {v1.push_back(i); } std::vector v2(v1.begin()+2, v1.end()?2); std::vector::iterator it = v2.begin();

for( ; it != v2.end(); it++) {std::cout<<*it++<<" "; }std::cout<

Select an option, then click Submit answer.

  • compilation error

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

  • program outputs 2 3 4 5 6 7

  • program outputs 2 4 6