CI

C++ Certified Professional Programmer

228 Questions

You can start the exam to practice all questions related to this exam.

Question No. 1

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

#include <vector> 

#include <iostream> class A {

public:

virtual int f() { return 10; } virtual ~A(){}

};

class B: public A { int f() {return 11; } virtual ~B(){}

};

int main (){

 

std::vector<A*>v1; for(int i = 10; i>0; i??)

{

i%2>0?v1.push_back(new A()):v1.push_back(new B());

}

std::vector<A*>::iterator it = v1.begin(); while(it != v1.end())

{

std::cout<<v1.back()?>f()<<"" ""; v1.pop_back();++it;

}

return 0;

}

"

Choose the correct option from the given list.
01 / 228

0 Discussions

Trending Exams