What happens when you attempt to compile and run the following code?
#include
#include
class A {
public:
virtual int f() { return 10; }
virtual ~A(){}
};
class B: public A {
int f() {return 11; }
virtual ~B(){}
};
int main (){
std::vectorv1;
for(int i = 10; i>0; i??)
{
i%2>0?v1.push_back(new A()):v1.push_back(new B());
}
std::vector::iterator it = v1.begin();
while(it != v1.end())
{
std::cout<
v1.pop_back();++it;
}
return 0;
}
Currently there are no comments in this discussion, be the first to comment!