What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
class A {
int a;
public:
A(int a) : a(a) {}
int getA() const { return a; } void setA(int a) { this?>a = a; }
};
struct Even {
bool operator ()(const A & a, const A &b) {
return (a.getA() % 2)==b.getA() % 2;
}
};
int main () {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
deque
deque
cout<< it?d.begin()< return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#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 val ostream & operator <<(ostream & out, const B & v) { out< template ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out< int main() { int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3}; deque d1(t, t+10); sort(d1.begin(), d1.end()); set s1(t,t+10); cout<<binary_search(s1.begin(),s1.end(), B(4))<<" "< return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main ()
{
int t[] = {1, 2 ,3 ,4 ,5, 6 , 7, 8 , 9, 10};
vector
deque
d1.empty();
v1.empty();
if (v1.isempty())
{
cout<<"I am empty ";
}
else
{
cout<<"I am not empty ";
}
cout<<v1.size()<<" "< return 0; }
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.back()?>f()<<" ";
v1.pop_back();++it;
}
return 0;
}