What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main(){
int myints[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 };
vector
set
set
for(set
cout<<*i<<" ";
}
for(set
cout<<*i<<" ";
}
cout< return 0; }
What will happen when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
while (start != end) {
std::cout << *start << " "; start++;
}
}
int main(){
vector
set
for(int i=10; i>0; i??) {
v.push_back(i);
s.push_back(i);
}
print(v.begin(), v.end()); print(s.begin(), s.end());cout< return 0; } The output will be:
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=0):val(v){}
int getV() const {return val;}
operator int () 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() { B t[]={3,2,4,1,5,6,10,8,7,9}; vector v1(t, t+10); transform(v1.begin(), v1.end(), v1.begin(), bind2nd(plus(), 1)); for_each(v1.rbegin(), v1.rend(), Out(cout));cout< return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#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;}
bool operator < ( const A & b) const { return a }; struct display { void operator() (const A & a) {cout << " " << a.getA();} }; struct add10 { void operator() (A & a) { a.setA(a.getA()+10) ;} }; int main() { int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; vector v1(t, t + 10); set s1(t, t + 10); for_each(v1.begin(), v1.end(), add10()); for_each(v1.begin(), v1.end(), display()); for_each(s1.begin(), s1.end(), add10()); for_each(s1.begin(), s1.end(), display()); return 0; }
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
void myfunction(int i) {
cout << " " << i;
}
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
vector
copy(t, t+10, v1.end());
for_each(v1.begin(), v1.end(), myfunction);
return 0;
}
Program outputs: